gpt4 book ai didi

c++ - 在我的代码中大量包含 .h 文件

转载 作者:搜寻专家 更新时间:2023-10-31 01:02:43 25 4
gpt4 key购买 nike

<分区>

我做了几年的程序员。

我总是被告知(也告诉其他人)你应该在你的 .c 文件中只包含你需要的 .h 文件。仅此而已。

但让我问 - 为什么?

使用今天的编译器,我可以包含项目的整个 h 文件,并且不会对编译时间产生巨大影响。

我不是在谈论包括 OS .h 文件,其中包括许多定义、宏和预处理命令。

只包括一个“MyProjectIncludes.h”。那只会说:

#pragma once
#include "module1.h"
#include "module2.h"
// and so on for all of the modules in the project

你说呢?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com