c – 有没有办法在每个编译单元中包含一个头而不修改每个源文件?

c – 有没有办法在每个编译单元中包含一个头而不修改每个源文件?,第1张

概述鉴于以下内容: >包含数千个C源文件的大型项目 >没有通用头文件(没有包含在每个源文件中的头文件) >说项目用g编译并由make管理 有没有办法在不修改每个源文件以包含新的头文件的情况下将定义(例如宏)包含到每个编译单元中? 来自man gcc: -include file Process file as if “#include “file”” appeared as the first lin 鉴于以下内容:

>包含数千个C源文件的大型项目
>没有通用头文件(没有包含在每个源文件中的头文件)
>说项目用g编译并由make管理

有没有办法在不修改每个源文件以包含新的头文件的情况下将定义(例如宏)包含到每个编译单元中?

解决方法 来自man gcc:

-include file

Process file as if “#include “file”” appeared as the first line of the primary source file. However,the first directory searched for file is the preprocessor’s working directory instead of the directory containing the main source file. If not found there,it is searched for in the remainder of the “#include “…”” search chain as normal. If multiple -include options are given,the files are included in the order they appear on the command line.

总结

以上是内存溢出为你收集整理的c – 有没有办法在每个编译单元中包含一个头而不修改每个源文件?全部内容,希望文章能够帮你解决c – 有没有办法在每个编译单元中包含一个头而不修改每个源文件?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1223870.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存