[英]How to define C++ preprocessor variable in Makefile
I have a C++ preprocessor written like this: 我有一个像这样写的C ++预处理器:
#ifdef cpp_variable
//x+y;
#endif
please anyone tell me how to define this in Makefile. 请有人告诉我如何在Makefile中定义它。
thanks! 谢谢!
Search your compiler documentation to find how to do that. 搜索编译器文档以了解如何执行此操作。
For example for g++
the syntax is : 例如对于g++
,语法是:
g++ -Dcpp_variable <other stuff>
Which corresponds to adding 这对应于添加
CPPFLAGS += -Dcpp_variable
in your makefile. 在你的makefile中。
添加到Makefile:
CPPFLAGS = -Dcpp_variable
语法是特定于编译器的,因为gcc使用-D
选项,如下所示: -Dcpp_variable
。
Take a variable in Makefile and whatever you need to define in it just add -DXXX. 在Makefile中获取一个变量,只需添加-DXXX即可在其中定义。 Where XXX in you case is cpp_variable. 在你的情况下XXX是cpp_variable。
For example 例如
COMPILE_OPTS = -DXXX COMPILE_OPTS = -DXXX
g++ -c $(COMPILE_OPTS) $< g ++ -c $(COMPILE_OPTS)$ <
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.