title: Error in compiling C code with variable name new with g++
body: <p>We are trying a modify some existing C projects i.e. we are trying to make some C++ function calls from the C code. We tried changing compiler from gcc to g++ but there were several compilation errors because of incompatibality. What we are trying to do is to call some C++ functions in C code without making any change to existing code. Simply changing the compiler didn't seem to do the trick. Hence we tried following:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  extern "C"
  {
      int func(int new ) {
          printf("in new func()\n");
      }
  }
  </code></pre>
  
  <p>When i compile it using command</p>
  
  <blockquote>
    <p>g++ -c hello.c -o hello </p>
  </blockquote>
  
  <p>we get following errors </p>
  
  <pre><code>hello.c:9: error:expected ‘,’ or ‘...’ before ‘new’.
  </code></pre>
  
  <p>Now we are aware that new is c++ keyword. As mentioned before, we are trying not to make any modifications to existing C code. Any suggestions ?</p>
  
  <p>These aren't the only errors. There are other errors related to structure declaration.</p>
  
  <blockquote>
    <p>attr.c:75: error: expected primary-expression before ‘.’ token</p>
  </blockquote>
  
  <p>At attr.c, line 75 is</p>
  
  <blockquote>
    <p>static post_op_attr error_attr = {.attributes_follow = FALSE }; </p>
  </blockquote>
  
  <p>The problem is that there are other C styled structure declaration and initialization done in the code so even if we rename the variable name, we would still have to modify other parts of the C program. Hence we are looking for a way to add C++ function calls to C code without modifying existing C code. </p>