Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to disable warning
Forum Updated to NodeBB v4.3 + New Features

How to disable warning

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 4.5k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Roy44
    wrote on 29 Aug 2016, 09:33 last edited by
    #1

    Hi,

    Maybe I'm not the first to ask this question.
    How can I disable some specific warning like C4100 ?
    (warning does not come from my code but from external library)
    I tried
    QMAKE_CXXFLAGS += -wd4100
    QMAKE_CXXFLAGS += -Wno-unused-parameter
    QMAKE_CXXFLAGS += /wd4100 /wd4101 /wd4102 /wd4189 /wd4996
    QMAKE_CXXFLAGS_WARN_ON = -Wall -Wno-unused-parameter nok
    QMAKE_CXXFLAGS += -wd4100 -wd4101 -wd4102 -wd4189 -wd4996
    QMAKE_CXXFLAGS_WARN_ON -= wd4100

    no one is working.
    So I compile with msvc14 for now and I will compile my application with clang for a MAC compilation.
    I would like to know how to disable these warning for the both compilers.
    Thanks.
    (Sorry for my bad english)

    1 Reply Last reply
    0
    • C Online
      C Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on 30 Aug 2016, 18:35 last edited by
      #2

      Personally I really don't like disabling warnings globally because of 3rd party libraries. My stance is that just because some library is not clean doesn't mean I don't want to keep my own code clean.

      What I usually do is wrap the includes from the offending library and disable the warning locally only for it.
      For example if I have:

      #include "dirtydirty.h" //causes some warning
      

      I create a wrapper header like this:

      //clean.h
      #ifdef _MSC_VER //just for MSVC
         #pragma warning (push)
         #pragma warning (disable: 4100 4101 4102)
            #include "dirtydirty.h"
         #pragma warning (pop)
      #elif ...// other compilers
      #endif
      

      and then include that:

      #include "clean.h"
      
      1 Reply Last reply
      3

      1/2

      29 Aug 2016, 09:33

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved