title: using C++ with namespace in C
body: <p>Using Eclpse on Linux I have defined a C++ class, named ABC (ABC.hpp):</p>
  
  <pre><code>#ifndef ABC_HPP_
  #define ABC_HPP_
  
  #include &lt;stdio.h&gt;
  
  // namespace my {            &lt;---- COMMENTED OUT
  
  class ABC {
  private:
      int m_number;
  public:
      ABC(int p_number);
      void doSomething();
      virtual ~ABC();
  };
  
  // } /* namespace my */      &lt;---- COMMENTED OUT
  
  #endif /* ABC_HPP_ */
  </code></pre>
  
  <p>and its implementation is (ABC.cpp):</p>
  
  <pre><code>#include "ABC.hpp"
  
  // using namespace my;       &lt;---- COMMENTED OUT
  
  ABC::ABC(int p_number) {
      this-&gt;m_number = p_number;
  }
  
  ABC::~ABC() {
      this-&gt;m_number = -1;
  }
  
  void ABC::doSomething() {
      printf("doing something (%d)\n", this-&gt;m_number);
  }
  </code></pre>
  
  <p>To use this class in C programs, I have created a layer containing these methods (ABCwrapper.h):</p>
  
  <pre><code>typedef void CABC;
  
  #ifdef __cplusplus
  extern "C" {
  #endif
  
  CABC* create_abc();
  void call_abc_methods(const CABC *p_abc);
  void destroy_abc(CABC *p_abc);
  
  #ifdef __cplusplus
  } // extern "C"
  #endif
  </code></pre>
  
  <p>and</p>
  
  <pre><code>#include "ABC.hpp"
  #include "ABCWrapper.h"
  
  extern "C" {
  
  CABC* create_abc() {
      ABC* abc = new ABC();
      return (ABC*)abc;
  }
  
  void call_abc_methods(const CABC *p_abc) {
      ABC* abc = (ABC*)p_abc;
      abc-&gt;doSomething();
  }
  
  void destroy_abc(CABC *p_abc) {
      ABC* abc = (ABC*)p_abc;
      delete abc;
  }
  
  }
  </code></pre>
  
  <p>That's fine and I can use the ABC class instance. But what about the define the ABC class in a name space, let's say "my"? If I remove the comment signs from all name space lines the IDE complains saying that the "Type 'ABC' could not be resolved".</p>
  
  <p>If I want to extend my C++ library I have to use name space for my classes but then I don't know how to use in wrappers. Please, help me to solve this mystery.</p>
  
  <p>Thank you.</p>
  
  <p>SK</p>