我有一个简单的helloWorld程序,下面是它的makefile
:
helloWorld: helloWorld.cpp
echo "Argument entered is $(foo)"
ifdef foo
echo "Defined.";
else
echo "Not defined.";
endif
g++ -Wall -pedantic -g helloWorld.cpp -o h
当我在命令行中使用make foo=bar
调用时,出现以下错误:
bar
"not set"
echo "Argument entered is bar"
Argument entered is bar
ifdef foo
make: ifdef: Command not found
make: *** [helloWorld] Error 127
我已经查看了一些关于这个错误的SO链接,但是还没有解决这个问题。
#ifdef
是一个 make 构造,你需要像 shell 命令一样缩进。不要这样做。移除前导制表符。 - Etan Reisner