title: extern "C" linkage inside C++ namespace?
body: <pre><code>namespace someNameSpace {
      extern "C" void doSomething()
          {
               someOperations();
          }
  }
  </code></pre>
  
  <p>I want to run <code>doSomething()</code> in both C++ and C environment.</p>
  
  <p>Is <code>someNameSpace</code> still encapsulating <code>doSomething()</code> if I expose it to <code>extern "C"</code> linkage?</p>
  
  <p>Is there a good way to share functions between C++ and C while avoiding polluting global namespace on C++ side?</p>
  
  <p><strong>Edit</strong>: Because this code is primarily used in C++ mode, while the C linkage is for test use only, I guess this is a better way to do it.</p>
  
  <pre><code>namespace someNameSpace {
      #ifdef COMPILE_FOR_C_LINKAGE
      extern "C"
      #else
      extern "C++"
      #endif
      { 
          void doSomething()
              {
                   someOperations();
              }
      }
  }
  </code></pre>