Results 1 to 4 of 4

Thread: Compiler Warnings from Qt

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Dortmund, Germany
    Thanked 10 Times in 8 Posts
    Qt products
    Windows Android

    Default Compiler Warnings from Qt


    when building my projects I get flooded with tons of compiler warnings - mostly not from my code, but from Qt itself. Therefore I don't see the important warnings (from my own code).

    Most of the warnings are
    warning: comparing floating point with == or != is unsafe [-Wfloat-equal]
    and among the most notorious Qt classes I find
    • QRect
    • QVector2d
    • QVector3d
    • QVector4d
    • QMatrix4x4
    • QQuaternion

    As this QtBug states,
    The code is intentional the way it is.
    Can I somehow disable compiler warnings generated by Qt code while keeping maximally paranoid error level for my own works?

    It actually renders the very idea of compiler warnings useless, if you drown in warnings you cannot get rid of.
    It might perhaps a n00b question, as I didn't find much about this problem on the web and in the Qt Bugtracker, so it apparently is'nt a problem to most people.

    My Environment:
    • Win7
    • Qt Creator 3.5.1,
    • Qt 5.4.2
    • MinGW 4.9.2 32b

  2. #2
    Join Date
    Oct 2009
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Unix/X11 Windows

    Default Re: Compiler Warnings from Qt

    I suppose that the lines generating these warnings are within inline methods of the classes you mention.

    Some compilers, such as GCC (and possibly MinGW), let you temporarily disable certain warnings. You could wrap the lines #including the offending files in a section disabling specific warnings, as in:
    Qt Code:
    1. #pragma GCC diagnostic push
    2. #pragma GCC diagnostic ignored "-Wfloat-equal"
    3. // ...
    4. #include <QRect>
    5. // ...
    6. #pragma GCC diagnostic pop
    To copy to clipboard, switch view to plain text mode 

    Not the most portable solution, I'm afraid, but unless Qt fixes their code (for instance by doing exactly this trick inside their code) I fear you are out of luck.

  3. The following user says thank you to yeye_olive for this useful post:

    sedi (25th November 2015)

Similar Threads

  1. Replies: 2
    Last Post: 11th March 2014, 12:02
  2. msvc Compiler or mingw compiler
    By Ashutosh2k1 in forum Qt Programming
    Replies: 3
    Last Post: 14th February 2011, 08:33
  3. Replies: 2
    Last Post: 18th November 2010, 08:01
  4. Strange compiler behaviour (compiler passes wrong argument)
    By SasaVilic in forum General Programming
    Replies: 2
    Last Post: 2nd November 2010, 11:36
  5. Where are my compiler warnings?
    By drhex in forum General Programming
    Replies: 5
    Last Post: 18th February 2009, 21:28

Tags for this Thread


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.