does g++ with extern "C" really gives the same environment as gcc does? -


i writing code using other packages in c languages , in c++ langauges. code, needs work c routines, , c++ classes well. plan is, include header files in c extern "c" {} method , use g++ compile.
so, copied headers in c directory , added headers , footers like,

#ifdef __cplusplus   extern "c" {   #endif   //... #ifdef __cplusplus   }   #endif   

however, still doesn't compile. made mock c program make clear how problem shows up.

main.c

#include <stdio.h> #include <a.h> //this problematic header file. int main() {   struct mmm m; //some struct in a.h   printf("how many times have compile this? %d\n",1000);   return 0; } 

a.h

#ifndef _a_h #define _a_h  #ifndef ... #define ... ... #endif  #include <b.h> #include <c.h>  #endif 

and gives me same error messages while compiling mock program ones during compilation of real code working on. , preprocessor macro functions defined in b.h , c.h. want assure these header files written inside extern "c" {}. mock program written in c language able check there no error messages gcc , works great.
wondering is, doesn't g++ extern "c" work gcc? or did miss something? there suggestions go around problem?

extern "c" not turn c++ compiler c compiler. code still has valid c++ code. cannot use new keywords identifiers, there no implicit cast void * other pointer types, , on. extern "c" affects linkage (basically, how code interacts other translation units). not change source language compiler accepts.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -