简体   繁体   English

为C源指定编译器标志

[英]Specifying compiler flags for C sources

I'm trying to find out how to specify flags for C sources in qmake project. 我试图找出如何在qmake项目中为C源指定标志。 I've tested the three options: 我已经测试了三个选项:

QMAKE_CFLAGS
QMAKE_CPPFLAGS
QMAKE_CXXFLAGS

QMAKE_CFLAGS is what I need. QMAKE_CFLAGS是我所需要的。 Both CPPFLAGS and CXXFLAGS are only applied to C++ sources. CPPFLAGS和CXXFLAGS都适用于C ++源。 What I'm worried about is that even though CFLAGS works, this option is not documented. 我担心的是,即使CFLAGS有效,该选项也没有记录。 It's just not in the list of qmake options: http://qt-project.org/doc/qt-5.0/qtdoc/qmake-variable-reference.html 它只是不在qmake选项列表中: http : //qt-project.org/doc/qt-5.0/qtdoc/qmake-variable-reference.html

So, how am I supposed to set C flags then? 那么,我该如何设置C标志呢?

On a sidenote, it's also weird there's no single option to set flags for both C and C++. 在一个旁注中,也很奇怪,没有一个选项可以同时为C和C ++设置标志。

Even though QMAKE_CFLAGS is undocumented, it does not mean you cannot use it. 即使未记录QMAKE_CFLAGS ,也并不意味着您不能使用它。 There are so many useful variables with qmake undocumented. qmake大量有用变量未记录。 I would not discourage you to stop using this if you wish. 如果您愿意,我不会阻止您停止使用此功能。

As for the C and C++ question: I think it is reasonable to set them separately as they are two different languages, but you can always set the same to both by having an interim variables or just duplicating the append statements. 关于C和C ++问题:我认为分开设置它们是合理的,因为它们是两种不同的语言,但是您始终可以通过使用临时变量或复制append语句来对它们进行相同的设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM