我正在阅读头文件winapifamily.h的定义,注意到WINAPI_FAMILY_PARTITION
的以下定义:
#define WINAPI_FAMILY_PARTITION(Partitions) (Partitions)
宏的一般用法(以示例为例)如下:
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
现在我很困惑,似乎它相当于
#if WINAPI_PARTITION_APP
为什么要使用#if WINAPI_FAMILY_PARTITION(...)
呢?
这是winapifamily.h头文件的相关部分:
/*
* Header files use the WINAPI_FAMILY_PARTITION macro to assign one or
* more declarations to some group of partitions. The macro chooses
* whether the preprocessor will emit or omit a sequence of declarations
* bracketed by an #if/#endif pair. All header file references to the
* WINAPI_PARTITION_* values should be in the form of occurrences of
* WINAPI_FAMILY_PARTITION(...).
*
* For example, the following usage of WINAPI_FAMILY_PARTITION identifies
* a sequence of declarations that are part of both the Windows Desktop
* Partition and the Windows-Phone-Specific Store Partition:
*
* #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PHONE_APP)
* ...
* #endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PHONE_APP)
*
* The comment on the closing #endif allow tools as well as people to find the
* matching #ifdef properly.
*
* Usages of WINAPI_FAMILY_PARTITION may be combined, when the partitition definitions are
* related. In particular one might use declarations like
*
* #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
*
* or
*
* #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
*
* Direct references to WINAPI_PARTITION_ values (eg #if !WINAPI_FAMILY_PARTITION_...)
* should not be used.
*/
#define WINAPI_FAMILY_PARTITION(Partitions) (Partitions)
const int MAX_WIDTH = 1024;
。当然,宏实现的操作现在可能是无操作。但它一直都是无操作吗?将来也会是吗? - Angew is no longer proud of SO