1.Preprocessor Glue: The ## Operator 预处理连接符:##操作符 Like the # operator, the ## operator can be used in the replacement section of a function-like macro.Additionally, it can be used in the replacement section of an object-like macro. The ## operator co
linux内核中offsetof与container_of的宏定义 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) /** * container_of - cast a member of a structure out to the containing structure * @ptr: the pointer to the member. * @type: the type
1.define是宏定义,程序在预处理阶段将用define定义的内容进行了替换.因此程序运行时,常量表中并没有用define定义的常量,系统不为它分配内存.const定义的常量,在程序运行时在常量表中,系统为它分配内存.2.define定义的常量,预处理时只是直接进行了替换.所以编译时不能进行数据类型检验.const定义的常量,在编译时进行严格的类型检验,可以避免出错.3.define定义表达式时要注意“边缘效应”,例如如下定义: #define N 2+3 //我们预想的N值是5,我们这