|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 涵天 于 2022-6-26 21:06 编辑
c的预编译 #include <stdio.h> 是把所有 头文件内容 导入 还是 只导入函数声明? 为什么我用 #include "my.h" 导入自己写的简单头文件时, 再用 gcc -E 只进行预编译 出来的 预编译文件打开会显示 出完整的定义的函数?
这是hello.c
- #include "my.h"
- int main(void)
- {
- return my_function();
- }
复制代码
这是my.h
- int my_function()
- {
- int variable = 0;
- return 1;
- }
- void my_function2()
- {
- int variable2 = 0;
- return 2;
- }
复制代码
- # gcc -E hello.c -o hello_cpp.c
- Administrator@windows MSYS ~/c
- # cat hello_cpp.c
- # 0 "hello.c"
- # 0 "<built-in>"
- # 0 "<command-line>"
- # 1 "hello.c"
- # 1 "my.h" 1
- int my_function()
- {
- int variable = 0;
- return 1;
- }
- void my_function2()
- {
- int variable2 = 0;
- return 2;
- }
- # 2 "hello.c" 2
- int main(void)
- {
- return my_function();
- }
复制代码
求解 谢谢! |
|