Namespaces not found by the compiler

My compiler does not find the namespace that I defined. I have four files and 3 namespaces.

charon.cpp

chin.cpp

chout.cpp

main.cpp

My namespaces are charon, charon_in and charon_out. The main problems arise in a particular charon.cpp file, so this file and chin.cpp too.

Errors:

g++    -c -g -MMD -MP -MF build/Debug/GNU-Linux-x86/sys/charon.o.d -o build/Debug/GNU-Linux-x86/sys/charon.o sys/charon.cpp
sys/charon.cpp:6:17: error: ‘charon_in’ is not a namespace-name
sys/charon.cpp:6:26: error: expected namespace-name before ‘;’ token
sys/charon.cpp:7:17: error: ‘charon_out’ is not a namespace-name
sys/charon.cpp:7:27: error: expected namespace-name before ‘;’ token
sys/charon.cpp:15:5: error: ‘chout_’ does not name a type
sys/charon.cpp:16:5: error: ‘chin_’ does not name a type
sys/charon.cpp: In constructor ‘charon::charon_::charon_()’:
sys/charon.cpp:31:39: error: ‘chin_’ has not been declared
sys/charon.cpp:31:55: error: ‘engine_input’ was not declared in this scope
sys/charon.cpp:32:40: error: ‘chout_’ has not been declared
sys/charon.cpp:32:57: error: ‘engine_output’ was not declared in this scope

charon.cpp

#include <iostream>
#include <boost/thread.hpp>
#include <boost/date_time.hpp>

using namespace std;
using namespace charon_in;
using namespace charon_out;

namespace charon
{

  class charon_
  {
  private:
    chout_ engine_output;
    chin_ engine_input;
    boost::thread input_thread;
    boost::thread output_thread;
    void start_threads();
    void stop_threads();

  public:
    charon_();
    charon_(const charon_& orig);
    ~charon_();
  };

  charon_::charon_(){
    input_thread = new boost::thread(&chin_::refresh, engine_input);
    output_thread = new boost::thread(&chout_::refresh, engine_output);
  }


};

chin.cpp

/* 
 * File:   chin.cpp
 * Author: josh
 * 
 * Created on 08 April 2012, 10:00
 */
#include <iostream>
#include <borland/conio.h>
#include <ncurses.h>
#include <deque>
#include <boost/thread.hpp>

using namespace std;
using namespace charon;
using namespace charon_out;

namespace charon_in
{

  class chin_
  {
  private:
    bool pause;

    iostream key_sequence;
    deque<char> key_queue;
    charon_* engine;

    inline iostream grab();


  public:
    chin_(const charon_& handle);
    chin_(const chin_& orig);
    ~chin_();

    void refresh();
    bool stop_check();
  };

  chin_::chin_(const charon_& handle) {
    engine = handle;
    pause = false;
  }
  chin_::chin_(const chin_& orig) {
  }
  chin_::~chin_() {
  }

  inline iostream chin_::grab(){
    iostream ret;
    ret << getch();
    return ret;
  }
  void chin_::refresh(){
    while((kbhit() != 0) && (key_queue.size() < 10))
    {
      char t = getch();
      key_queue.push_back(t);
    }
  }
  bool chin_::stop_check(){
    return pause;
  }
};

So this is the code, and I triple checked everything. I even see namespaces in the netbean browser. Thus, I am 101% sure that I correctly declared the namespaces, I actually had them all as one namespace, but I decided that this is a problem, so I separated them.

, . , , , . , , , .

, , - , ; , , . .

+3
2

, ( ) using directive:

// using namespace test;  // Error test is not known to be a namespace
namespace test {}
using namespace test;     // Fine -- test is known

Wayne , , , -, , , .

+5

.cpp. .h , .

, chin.h chin.h charon.cpp.

namespace charon_in 
{ 

  class chin_ 
  { 
  private: 
    bool pause; 

    iostream key_sequence; 
    deque<char> key_queue; 
    charon_* engine; 

    inline iostream grab(); 


  public: 
    chin_(const charon_& handle); 
    chin_(const chin_& orig); 
    ~chin_(); 

    void refresh(); 
    bool stop_check(); 
  }; 
}
+3

All Articles