如何触发__cplusplus(C ++)#ifdef? [英] How to trigger the __cplusplus (C++) #ifdef?
本文介绍了如何触发__cplusplus(C ++)#ifdef?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#ifdef __cplusplus
// C++ code
#else
// C code
#endif
结构是这个.
我的问题是,如何真正触发#ifdef
?
The structure is this.
My question is, how to actually trigger the #ifdef
on?
我的意思是,在程序中?我写的什么代码可以打开#ifdef
?
I mean, in program? What code I write can turn #ifdef
on?
例如,在这种情况下. 是
For example, in this case. is that
#define __cplusplus
将其打开吗?
推荐答案
#define __cplusplus"
"#define __cplusplus"
会放吗?
是的,它将启用".
__cplusplus
应该由C ++编译器自动定义. C ++使用不同的名称修改和通常用于使C标头与C ++兼容的宏:
__cplusplus
should be automatically defined by C++ compiler. C++ uses different name mangling and the macro often used to make C headers compatible with C++:
#ifdef __cplusplus
extern "C" {
#endif
...
#ifdef __cplusplus
}
#endif
这篇关于如何触发__cplusplus(C ++)#ifdef?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文