功能一:简单的替换、预处理等
功能二:#ifndef/#define/#endif 防止头文件重复引用
功能三:连接
#define CONNECTION(_x,_y) _x##_y INT a = CONNECTION(10,24); // a = 1024 STRING s = CONNECTION("Lu","key"); // s = "Lukey"
功能四:转换成char
#define CONVERT_TO_CHAR(_x) #@_x CHAR c = CONVERT_TO_CHAR(1); // c = ‘1‘
功能五:转换成String
#define CONVERT_TO_STR(_x) #_x STRING a = CONVERT_TO_STR(1); //a = "1" enum TEST { TEST_T_01, TEST_T_02, } STRING b = CONVERT_TO_STR(TEST.TEST_T_02); //b = "TEST_T_02"
宏的几个特殊的使用
时间: 2024-10-31 12:00:59