[SOLVED:] Parameters to gcc, like -Wno-comment

  • This must be very basic, but it's already taken an hour..
    I am trying to tell -Wno-comment to gcc!
    I have googled and searched here.

    The Project page gives me parameters to qmake, not to gcc? And besides, the field is not editable.
    The .pro file is probably it, but CONFIG += -Wno-comment certainly does not work.
    And http://qt-project.org/doc/qt-4.8/qmake-project-files.html I seem to have a blind eye on..

  • Lifetime Qt Champion

  • I saw in http://comments.gmane.org/gmane.comp.lib.qt.general/36895 that

    @QMAKE_CXXFLAGS += -Wno-comment@

    in the .pro file should work, but there is some finger trouble (more below). Same matter with


    which is too wide, I certainly don't want to switch off all warnings.

    The finger trouble is that either it tells me

    @Configuration unchanged, skipping qmake step.@

    even if I try to Save or Build or Rebuild or whatever..)
    or I get

    @mingw32-make: 'debug/S_ChanSched.o' is up to date.@

    even if I do Build. Seems like the tool tries to protect compiled files, perhaps to avoid having to rebuild other dependencies. But I am used to "Build" meaning unconditional build.

    Q1. Are the .pro file examples correct?

    Q2. How do I get change in it to make new makefile, and why isn't that automatic?

    Q3. How do I do a forced build?

    I am having so much finger trouble with this tool, (which up to now doesn't seem like KISS). And I can't say I am a newbie to the art either, having done this for 35 years! Ok, maybe it is that gray hair!-)


  • Lifetime Qt Champion

    If the rebuild doesn't do, just delete the shadow build. From time to time it's the only option on Windows...

    Also depending on what you modify (i.e a warning flag) make won't rebuild everything since it's does not modify any actual file. Should there be something that touches every file of the project or mark something as force-rebuild when a flag is modified ? Maybe. That could make the object of a feature request for QtCreator

  • None of these seem to be picked up from the .pro file:

    @QMAKE_CXXFLAGS += -Wno-comment
    QMAKE_CXXFLAGS_WARN_OFF += -Wno-comment@

    so they must be wrong. If I quote them into qmake, they don't appear in the build either. I have some Qt users with me, and have we tried.. Help!

  • I wise guy here guessed that since I have plain C project, this this might help:

    @QMAKE_CFLAGS += -Wno-comment@

    It did, since we now got it in the gcc build string:

    @gcc -c -pipe -fno-keep-inline-dllexport -Wno-comment -g -Wall -Wextra -DUNICODE -D_AUTROKEEPER_QT_PLAINC_ -D_COMPILE_WARNINGS_A_ -I..\autrokeeper_Qt_plainC -I"..\autrokeeper" -I"..\avr8" -I"..\scheduler" -I"." -I"C:\Qt\Qt5.1.0\5.1.0\mingw48_32\mkspecs\win32-g++" -o debug\S_ChanSched.o ..\scheduler\S_ChanSched.c@

    But I still got the "multi-line comment" error. Is this because it came before -Wall? If so, how do I move -Wall in front of -Wno-comment? I have experimentet and can't see a command that removes the last -Wall.

    Do I have to specify some rule in some file to get rid of the -Wall, and then introduce one myself in from of the -Wno-comment?

  • Lifetime Qt Champion

    You might have to edit the win32-g++ mkspec for that

  • Again thanks for not giving me up!
    I digged based on that cue, and the answer seems to go like this:

    Comment out (with a #)

    @QMAKE_CFLAGS_WARN_ON = -Wall -Wextra@

    from the file (Qt installed at standard place on windows):


    and add this in the Qt Creator .pro file:

    @QMAKE_CFLAGS += -Wall -Wextra
    QMAKE_CFLAGS += -Wno-comment@

    This will make -Wno-comment overtake -Wall for that explicit warning. Build now looks like this, with -Wno-comment parsed after -Wall etc. by gcc:

    @gcc -c -pipe -fno-keep-inline-dllexport -Wall -Wextra -Wno-comment -g -DUNICODE -D_AUTROKEEPER_QT_PLAINC_ -D_COMPILE_WARNINGS_A_ -I..\autrokeeper_Qt_plainC -I"..\autrokeeper" -I"..\avr8" -I"..\scheduler" -I"." -I"C:\Qt\Qt5.1.0\5.1.0\mingw48_32\mkspecs\win32-g++" -o debug\S_ChanSched.o ..\scheduler\S_ChanSched.c@

    This seems to work. Please advice if there are any errors in my reasoning above. I will add [SOLVED] after some time if it's all ok.

  • Lifetime Qt Champion

    If you want to use these option for several or all your projects, you can modify the mkspec or create your own and use that one

  • Ok, where do I in case put my own? Will it override the original, or will the original have to be removed?

  • Lifetime Qt Champion

    if you create your own, you just need copy/paste the original folder and rename it (plus make the modifications you want). Then you'll need to use the new name in the Kits configuration.

  • I moved the \win32-g++ directory with the modified qmake.conf to a local directory, inside my project. Then I went through this in Qt Creator (but I am not certain if this is right and what you meant!):

    @| Projects
    | Manage Kits
    | Build & Run
    | Kits
    | Manual
    | Add .. name etc plus most importantly:
    | Qt mskspec: path to new \win32-g++ directory@

    I now have two Kits, the default and my new.

    But do observe, I also had to move the directory "\common" to the same level as the "\win32-g++" directory, as I got a complaint. Does this have any side effect (i.e. is there a tool that would update any file(s) in any of these two directories)?

  • Lifetime Qt Champion

    I would just have added the new mkspec in the same directory but with a different name i.e "mywin32-g++"

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.