求教extern "C" 的标准写法的一个疑问
//在.h文件的头上
#ifdef __cplusplus
#if __cplusplus
extern "C"{
#endif
#endif /* __cplusplus */
//.h文件结束的地方
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
上面的条件编译中为什么加#if啊,我感觉有#ifdef判断__cplusplus就可以了,用#if不是多此一句吗?
请问这种标准写法好在哪里呢?
[解决办法]
#if显然是多余的,写此代码的人,想依样画葫芦却画蛇添足了,好的写法是:
#ifdef __cplusplus
extern "C"
{
#endif
...
#ifdef __cplusplus
}
#endif