加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 10:55:21 所属栏目:百科 来源:网络整理
导读:鉴于以下内容: 包含数千个C源文件的大型项目 没有通用头文件(没有包含在每个源文件中的头文件) 说项目用g编译并由make管理 有没有办法在不修改每个源文件以包含新的头文件的情况下将定义(例如宏)包含到每个编译单元中? 解决方法 来自man gcc: -include fi
鉴于以下内容:

>包含数千个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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读