Pergunta

Estou envolvido com um projeto de software escrito no QT e construído com QMake e GCC no Linux. Temos que vincular a uma biblioteca de terceiros de qualidade bastante baixa e vomitar toneladas de avisos. Eu gostaria de usar -w -wall em nosso código -fonte, mas passe -w para a biblioteca desagradável de terceiros para manter o console livre de ruído e desordem para que possamos nos concentrar na qualidade do código.

No QMake, existe uma maneira de adicionar condicionalmente cflags/cxxflags a determinados arquivos e bibliotecas?

Foi útil?

Solução

Jonathan, I think the problem is where your source files are including header files from 3rd party libraries, and you want to switch off the warnings for the latter.

Kevin, i think you can use pragmas to control warnings : gcc diagnostic pragmas

You could add these before and after any #includes for 3rd party libs.

Outras dicas

What if you include your library using -isystem.

In the project file e.g.:

QMAKE_CXXFLAGS += -isystem /usr/local/boost_1_44_0

Kevin,

qmake CONFIG+=debug QMAKE_CXXFLAGS_WARN_ON=-w QMAKE_CFLAGS_WARN_ON=-w

should do (use CONFIG+=release if you wish...)

Normally, you'd build the third-party library in a separate directory from your own code, so you would have a different makefile for it, so you could put a different set of flags for that compilation.

If you've mixed the third-party library code with your own code, you have set yourself up for a maintenance nightmare.

As Martin wrote adding the include directory via

QMAKE_CXXFLAGS += -isystem ...

suppresses warnings just in the respective headers. No need to disable warnings for any source files of your project (or even project-wide) or mess with #pragmas or wrappers files.

Note that if you're using QtCreator you'll still (i.e. additionally) want add the directory to INCLUDEPATH so the indexer picks up the headers.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top