我有这个文件:
// File.cpp
int main() {
FuncToChange(4, 6, 9, 12);
}
现在,我需要获得此行为:
// Config.h
#define FuncToChange($1, $2, $3, $4) NewFunc($1, $3, $4)
// File.cpp
#include "Config.h"
int main() {
FuncToChange(4, 6, 9, 12);
}
如何在不修改原始“File.cpp”文件的情况下执行此操作,即不显式#include“Config.h”?
是否可以从makefile或IDE强制包含头文件(在本例中为CodeBlocks)?
谢谢!
平台:
CodeBlocks 10.05
GCC / MinGW的
Windows 7
答案 0 :(得分:1)
在preprocessor options页面上的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.