如何在Makefile中添加#define? [英] How to add #define in Makefile?
本文介绍了如何在Makefile中添加#define?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个C ++项目,其中需要在某些CXX文件中定义一个变量.我有近800个文件,其中我需要为200个文件定义一个变量.所以我想在makefile中定义它.那么我们该怎么做.
I have a c++ project in which i need to define a variable in some CXX files. I have nearly 800 files out of which i need to define a variable for 200 files. So i was thinking to define it in makefile. So how can we do that.
推荐答案
使用可以使用头文件
defining.h:
defining.h:
#define deff 10
main.cxx或您要使用的任何文件
main.cxx or any file where you want to use
#include "definitions.h"
另一种方法是在编译时给出以下参数g ++ -DMYDEF file1.cpp file2.cpp ------ file200.cpp -o abc.exe
The other way is while compiling give following arg g++ -DMYDEF file1.cpp file2.cpp ------ file200.cpp -o abc.exe
这篇关于如何在Makefile中添加#define?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文