"#if cpp"在C文件中的含义是什么?

int*_*skh 2 c

这些天我正在研究一些源代码.在某些代码中,我发现了这些.不知道这意味着什么.有任何想法吗?

#include "pth_p.h"

#if cpp

#ifndef PTH_DEBUG

#define pth_debug1(a1)                     /* NOP */
#define pth_debug2(a1, a2)                 /* NOP */
#define pth_debug3(a1, a2, a3)             /* NOP */
#define pth_debug4(a1, a2, a3, a4)         /* NOP */
#define pth_debug5(a1, a2, a3, a4, a5)     /* NOP */
#define pth_debug6(a1, a2, a3, a4, a5, a6) /* NOP */

#else

#define pth_debug1(a1)                     pth_debug(__FILE__, __LINE__, 1, a1)
#define pth_debug2(a1, a2)                 pth_debug(__FILE__, __LINE__, 2, a1, a2)
#define pth_debug3(a1, a2, a3)             pth_debug(__FILE__, __LINE__, 3, a1, a2, a3)
#define pth_debug4(a1, a2, a3, a4)         pth_debug(__FILE__, __LINE__, 4, a1, a2, a3, a4)
#define pth_debug5(a1, a2, a3, a4, a5)     pth_debug(__FILE__, __LINE__, 5, a1, a2, a3, a4, a5)
#define pth_debug6(a1, a2, a3, a4, a5, a6) pth_debug(__FILE__, __LINE__, 6, a1, a2, a3, a4, a5, a6)

#endif /* PTH_DEBUG */

#endif /* cpp */
Run Code Online (Sandbox Code Playgroud)

Eva*_*ran 10

它正在测试预处理器可见的某个常量命名cpp(可能是宏)是非零的.

通常情况是宏应该全部大写,使他们更加明显,但他们没有被(这里显然是这种情况).

我的猜测是,它代表了C++和所包含的头一个(也许pth_p.h?)定义它,如果正在使用C++编译器.如果是这种情况,可以使用更多标准的东西,例如:

#ifdef __cplusplus
Run Code Online (Sandbox Code Playgroud)