gcc编译头文件搜索路径
2021-3-16
预处理器搜索头文件的方法:1 双引号包含的头文件 首先在包含它的头文件所在的目录搜索,比如/usr/include/sys/stat.h 包含 #include "types.h", GCC首先在/usr/include/sys目录寻找types.h。 然后在双引号search path寻找。
Why do you have to link the math library in C
2021-3-19
有时候,我们使用了数学函数,确不用链接-lm,例如:$ cat test.c#include #include int main(){ printf("%lf\n", log(2));}$ cc test.c$ ./a.out0.693147$ ldd
gcc打印包含的头文件
2021-5-7
有时候添加了-I选项,指定自定义的路径时,可能和系统路径的头文件冲突,为了确定使用哪个头文件。可以使用-H选项。比如,有一个test.c,尖括号包含time.h$ cat test.c#include void main(){}然后$ touch time.h$ cc -I. -H
weak, alias的用途
2024-1-22
看下面的例子就清楚了。static int __def_eth_init(bd_t *bis){ return -1;}int board_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init")));
per thread variable
2024-5-9
每线程变量,官方叫法是:Thread-local storage (TLS)。这种变量每个线程都会有一个实例,很多场景需要每线程变量,最典型的就是errno。每线程变量,使用__thread关键字定义,这个关键字不是c语言标准定义的,而是业界(编译器开发者)根据实际需要扩展的。下面例子,主线程和子线
Copyright © linuxdev.cc 2017-2024. Some Rights Reserved.