Conditionally disable warnings with qmake/gcc?

后端 未结 5 1127
予麋鹿
予麋鹿 2021-01-02 22:20

I am involved with a software project written in Qt and built with qmake and gcc on Linux. We have to link to a third-party library that is of fairly low quality and spews

相关标签:
5条回答
  • 2021-01-02 22:45

    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.

    0 讨论(0)
  • 2021-01-02 22:53

    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.

    0 讨论(0)
  • 2021-01-02 22:53

    Kevin,

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

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

    0 讨论(0)
  • 2021-01-02 22:55

    What if you include your library using -isystem.

    In the project file e.g.:

    QMAKE_CXXFLAGS += -isystem /usr/local/boost_1_44_0
    
    0 讨论(0)
  • 2021-01-02 23:05

    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.

    0 讨论(0)
提交回复
热议问题