生成文件
ifeq ($(wifiSim),1)
WIFISIM :=1
endif
all: test.cpp
test.cpp : test.o
./a.out
test.o :
c++ test.cpp
测试.cpp
#include <iostream>
using namespace std;
int main()
{
#ifdef WIFISIM
cout << "Inside wifisim = 1" << endl;
#else
cout << "Outside wifisim = 1" << endl;
#endif
return 0;
}
我想WIFISIM
在test.cpp
. 我正在运行make wifiSim=1 all
但 else 正在执行test.cpp
有什么方法可以在不改变编译方式的情况下test.cpp
做到这一点,因为我需要在许多文件中使用这个标志 WIFISIM 并且我不想改变它们的编译方式。