Yes.
If you have control over the C code, then inside your C header files you should:
#ifdef __cplusplus extern "C" { #endif
Thus, they can be correctly interpreted when included with both C code files and CPP.
If you include C code in your C ++ through the header, and it does not include the code above, and you do not have enough control over it to make the necessary changes, be sure to use, for example.
extern "C" { #include "some_c_header.h" };
Please note that you can also use this as a modifier for ads, for example:
extern "C" void someFunction();
Please note that C ++ has this mechanism for importing C functionality. C does not have one for importing C ++, and an attempt to include C ++ code in the C compilation unit will quickly end up with a bunch of error messages. One consequence of this is that your main function should be C ++.
sje397
source share