[英]GCC - define my own command line option that adds a list of options
Using GCC to compile C++ code: there's a big list of options (warnings, optimisations etc) I want to always compile with. 使用GCC编译C ++代码:我想要总是编译的选项列表(警告,优化等)。 It's tiresome to keep pasting them into the command line.
将它们粘贴到命令行中是很烦人的。 Can I do something like
我能做点什么吗
g++ test.cpp -o test.o -myoptions
where "-myoptions" would enable a list of options like 其中“-myoptions”将启用一个选项列表,如
-pedantic
-Wall
-O2
-Wshadow
-...
that I've defined somewhere? 我已经定义了某个地方?
I've tried searching but couldn't find a guide for this. 我试过搜索但找不到这方面的指南。 Is it possible or do I have to use make files?
是否可以或者我必须使用make文件? System is windows 7 if that's relevant.
如果相关,系统是Windows 7。 Thanks
谢谢
edit: in case someone searches for this in the future, windows specific answer: go to control panel -> system -> advanced system settings -> environment variables, create new system variable named "myoptions" and value "-option1 -option2 -option3 ...". 编辑:如果将来有人搜索这个,windows具体答案:转到控制面板 - >系统 - >高级系统设置 - >环境变量,创建名为“myoptions”的新系统变量和值“-option1 -option2 -option3 ...“。 Then compile with "g++ test.cpp -o test.o %myoptions%"
然后用“g ++ test.cpp -o test.o%myoptions%”编译
You can set an environment variable: 您可以设置环境变量:
export CXXFLAGS="-Wall -O3 -std=c++11"
and use 并使用
g++ $CXXFLAGS test.cc -o test
Note that some variables are more-or-less standardized and when you set them, several build system will automatically use them. 请注意,某些变量或多或少是标准化的,当您设置它们时,多个构建系统将自动使用它们。 Among others, google for
CFLAGS
, CPPFLAGS
, CXXFLAGS
, ... 其中,谷歌的
CFLAGS
, CPPFLAGS
, CXXFLAGS
,...
Here's also a starting point on SO. 这也是SO的起点 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.