在 C/C++ 中定义 (XXXX) 宏?

defined(XXXX) macro in C/C++?

我正在浏览 BSON 源代码,发现了一些我以前从未见过的东西。

Line 22 in bson-macros.h:

#if !defined(BSON_INSIDE) && !defined(BSON_COMPILATION)
#error "Only <bson.h> can be included directly."
#endif

上面的defined(XXXX)宏是什么?我可以猜到它的作用,但我似乎找不到任何关于它的文档。它特定于某些编译器吗?它在 Microsoft Visual C++ 上给我一个 W4 警告(我正试图在我的项目中解决)。

来自6.10.1

The expression that controls conditional inclusion shall be an integer constant expression except that: identifiers (including those lexically identical to keywords) are interpreted as described below;166) and it may contain unary operator expressions of the form

  defined identifier

or

  defined ( identifier )

which evaluate to 1 if the identifier is currently defined as a macro name (that is, if it is predefined or if it has been the subject of a #define preprocessing directive without an intervening #undef directive with the same subject identifier), 0 if it is not.

它不是 macro - 它是一个运算符。