下面的小程序我不能理解,请各位帮助

来源:百度知道 编辑:UC知道 时间:2024/06/07 02:09:59
#ifdef __cplusplus
extern "C" {
#endif

//一段代码

#ifdef __cplusplus
}
#endif
个人理解为:如果定义了__cplusplus,则对 extern "C" { 进行编译.但这个{代表什么意思,#endif就中止编译了,那么下面的程序怎么办? 接下来是第二个#ifdef __cplusplus ,意思是如果定义了__cplusplus了就对"}"进行编译?这有什么意义?

#ifdef __cplusplus //一般如果编译了就不编译了,这样在用头文件的时候可以用多次#include<文件名>把它包括进来,//否则用第二次#include<文件名>的话,编译系统就报错!
extern "C" {
#endif

//一段代码

#ifdef __cplusplus
}
#endif