Results 1 to 8 of 8

Thread: Conditionally disable warnings on ceratin source files in qmake?

  1. #1
    Join Date
    Apr 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Conditionally disable warnings on ceratin source files in qmake?

    Hello,

    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 tons of warnings. I would like to use -W -Wall on our source code, but pass -w to the nasty third-party library to keep the console free of noise and clutter so we can focus on our code quality.

    In qmake, is there a way to conditionally add CFLAGS/CXXFLAGS to certain files and libraries?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Conditionally disable warnings on ceratin source files in qmake?

    There's QMAKE_CXXFLAGS and "CONFIG += no_warn" (or was it "CONFIG -= warn_on"?).
    J-P Nurmi

  3. #3
    Join Date
    Apr 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Conditionally disable warnings on ceratin source files in qmake?

    I only would like to disable warnings for the bad third-party header files, but very much would like to keep warnings on my code!

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Conditionally disable warnings on ceratin source files in qmake?

    So it's not a separate library but its sources are included to the main project?
    J-P Nurmi

  5. #5
    Join Date
    Apr 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Conditionally disable warnings on ceratin source files in qmake?

    yes, .h files included from our code

  6. #6
    Join Date
    Apr 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Conditionally disable warnings on ceratin source files in qmake?

    We have to use their headers to interface with their API.

  7. #7
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Thanks
    2
    Thanked 29 Times in 28 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Conditionally disable warnings on ceratin source files in qmake?

    The compiler flags can only be set for c/cpp files.
    If you code a perfect cpp file that includes an ugly third party header it is bad luck for you.
    You should force the third party developers to stick to some guidelines and demand a measurable quality from them.

    Maybe gcc provides an option to selectively switch off a certain warning.
    I know this from the Green Hills compiler that we use for automotive controllers. Every possible warning has a number that can be used as argument for that option.

  8. #8
    Join Date
    Feb 2011
    Posts
    2
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Conditionally disable warnings on ceratin source files in qmake?

    I think you can do it by these:
    Qt Code:
    1. #pragma GCC diagnostic ignored "-Wunused-parameter"
    2. #pragma GCC diagnostic ignored "-Wunused-variable"
    3. #include "third_party.h"
    4. #pragma GCC diagnostic warning "-Wunused-parameter"
    5. #pragma GCC diagnostic warning "-Wunused-variable"
    6. #include "your_header.h"
    To copy to clipboard, switch view to plain text mode 

    Reference:
    http://gcc.gnu.org/onlinedocs/gcc-4....nostic-Pragmas
    http://gcc.gnu.org/onlinedocs/gcc-3....ning%20Options

  9. The following user says thank you to sevenjay for this useful post:

    TheRonin (23rd August 2013)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.