从程序中获取编译器选项 [英] Get the compiler options from the program

查看:64
本文介绍了从程序中获取编译器选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

c ++中是否有任何宏(使用gcc)来获取用于构建可执行文件的编译选项?我确定我在对话框中看到了类似的内容.

Is there any macro in c++ (using gcc) to get the compilation options used to build the executable ? I'm sure I saw something like that in some about dialogs.

任何帮助将不胜感激

PS:而>检测GCC编译时标志的问题二进制对找到激活的用于编译程序的选项感兴趣,对从该程序源中找到用于编译程序的确切命令行选项很有趣.

PS: while the question in Detect GCC compile-time flags of a binary interests in finding the options activated to compile a program, I'm interesting in finding the exact command line options used to compile my program from within this program source.

推荐答案

因为我使用的是qmake构建系统,所以遇到了以下解决方案:

Because I'm using qmake build system I came across this solution :

我将此行添加到我的专业文件的末尾:

I added this line to the end of my pro file :

QMAKE_CXXFLAGS += -DFLAGS=\"$$QMAKE_CXXFLAGS $$QMAKE_CXXFLAGS_RELEASE\"

然后从FLAGS宏中检索了我想要的内容

then retrieved what I want from the FLAGS macro

这篇关于从程序中获取编译器选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆