69,373
社区成员
发帖
与我相关
我的任务
分享
const char *EVENT_START = "Start Event";
#define EVENT_START "Start Event"
#ifndef USE_CONST_MODE
#define EVENT_START "Start Event"
......
#else
const char *EVENT_START = "Start Event";
......
#endif
const char *EVENT_START = "Start Event";
//占用的内存有俩个部分: EVENT_START和"Start Event"
//对于"Start Event"和宏定义没有区别
//变量EVENT_START, 如果从来没有引用/使用过,一般会被优化掉,不用担心
//使用宏的缺点是没有类型,不够安全,容易出错。