- 预处理符号
__FILE__: 当前文件的原文件名字
__LINE__: 文件当前的行号
__DATA__: 文件编译的日期
__TIME__: 文件编译的时间
__SDTC__: 如果编译器准寻ANSIC,其值为1,否则未定义
- #define宏和#undef宏
#define _(name) name
#undef _
- ##和#
##将两个字符串链接起来
#将后面的当做字符串处理
#define name(a,b) a##b
#define name(a) #a - 编译的过程
预处理->编译->汇编->链接
预处理:gcc -E test.c -o test.i
编译:gcc -S test.i -o test.s
汇编:gcc -c test.s -o test.o
链接生成可执行文件 - 命令readelf nm objdump size
- attribute ():
attribute ((unused))修饰一个变量或者函数,当这个变量和函数未使用时不会在编译时,提示warning,未使用的变量或函数
attribute ((constructor))和 attribute ((destructor))
如果函数被设定为constructor属性,则该函数会在main()函数执行之前被自动的执行;若函数被设定为destructor属性,则该函数会在main()函数执行之后或者exit()被调用后被自动的执行。