When using C ++ CCS C compiler
Source
Often in CCS previous code, often appear in the .h file
#ifdef __cplusplus
extern "C"{
#endif
*一段代码
#ifdef __cplusplus
}
#endif
Code Analysis
- #ifdef usage
#ifdef 被定义的
*代码
#endif
The meaning of the code above is as follows: If the definition of the "defined", then execute the code.
- __cplusplus
__cplusplus is set to c ++ macros. - extern "C" {}
in C ++ in order to support overloading, the assembly code generated by the compiler, to name some processing functions, such as the return type of the function is added so on. In C, a function name only simply will not add other information. In other words: C ++ and C processing function name generated is not the same. So this statement is to execute C language statements in C ++. - Overall meaning of the source code
if the execution of the C ++ code, then extern "C" {} reputation valid, the case wherein the code is compiled manner through the C's.
To summarize
In order to perform both the code C ++, it can be performed under C.