我知道您可以在 gcc 中使用 -include
编译器标志将头文件放在文件之上,但是是否可以在其他头文件声明的末尾包含头文件的一个文件。例如,我在 C 源文件中有以下声明。
#include "a.h"
#include "b.h"
我愿意,成为
#include "a.h"
#include "b.h"
#include "inserted.h"
而不是
#include "inserted.h"
#include "a.h"
#include "b.h"
最佳答案
使用
-include a.h -include b.h -include inserted.h
为所有 *.h
文件添加 header 保护(无论如何都应该存在……;-)。
关于c - 如何让编译器将头文件放入源文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16171760/