- 你把 test.h 中 的 int a; 改为 int a = 0; 或 int a __attribute__ ((section(".bss"))); 编译就会看见错误了。
- 你把 sort 函数的那个 C 文件这样改一下:
- #include <stdio.h>
- #include "test.h"
- int b;
- void sort(void)
- {
- printf("*****************\n");
- a = 10;
- b = 1078530011;
- }
复制代码
main函数的 C 文件这样改一下:- #include <stdio.h>
- #include "test.h"
- float b;
- void sort(void);
- int main(void)
- {
- sort();
- printf("a = %d, b = %f\n", a, b);
- return 0;
- }
复制代码
编译运行,你会发现更奇怪的事。
|