编译时打印宏变量内容

1
2
3
4
5
6
7
8
9
#define PRINT_MACRO_HELPER(_x) #_x
#define PRINT_MACRO(_x) #_x " = " PRINT_MACRO_HELPER(_x)
 
#define DEFINED_PI 3.14
#define DEFINED_NULL
#pragma message(PRINT_MACRO(DEFINED_PI))
#pragma message(PRINT_MACRO(DEFINED_NULL))
#pragma message(PRINT_MACRO(UNDEFINED))
//#error print stop here.

refer to: https://blog.csdn.net/xshbx/article/details/7981564