title: undefined reference to c functions in c++ code
body: <p>I have a strange problem: the code bellow perfectly compiled.<br />
  src.cpp:<br /></p>
  
  <pre><code>extern "C" {
      #include "header.h"
  }
  
  void A::Execute() {
      B::Instance().Reset(ix);
      c_func(ix);// this is c functions declared in header.h
      C::Instance().Erase(ix);
  }
  </code></pre>
  
  <p>But when I comment out the c_funk() I get linkage error in all places where I use c functions from the header.h file.</p>
  
  <p>With that minor change:</p>
  
  <pre><code>void A::Execute() {
      B::Instance().Reset(ix);
      //c_func(ix);// this is c function declared in header.h
      C::Instance().Erase(ix);
  }
  </code></pre>
  
  <p>I get:  undefined reference to c_func().<br />
  Any ideas how to solve it? Thanks.</p>
  
  <p>Update:<br />
  I have added a dummy function to header.h: foo_for_linkage_problem();<br />
  and in such way solved the problem. As I understand the linker try to make some optimization that couses this problem. new code:</p>
  
  <pre><code>void A::Execute() {
      B::Instance().Reset(ix);
      foo_for_linkage_problem();// this is c empty function declared in header.h 
      C::Instance().Erase(ix);
  }
  </code></pre>