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. Qt 5.10 tries to compile my precompiled headers as C instead of C++, obviously fails
Forum Updated to NodeBB v4.3 + New Features

Qt 5.10 tries to compile my precompiled headers as C instead of C++, obviously fails

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 3.4k 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.
  • ZueukZ Offline
    ZueukZ Offline
    Zueuk
    wrote on last edited by
    #1

    Hi all,

    I've got a Qt project created in Visual Studio, so it has this precompiled header file named "stdafx.h". Obviously I'm on Windows and using the MSVC compiler.

    Now, everything worked fine before Qt 5.10, but now I started getting all kinds of weird errors which lead me to find a "-TC" compiler option in the makefile, that is supposed to force the compiler to treat a file as C instead of C++.

    Qt 5.9.3 did not add this option, but the version 5.10 does for some reason - is there a way to disable it?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What did you use to create the project ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • ZueukZ Offline
        ZueukZ Offline
        Zueuk
        wrote on last edited by
        #3

        The project must have been created using Visual Studio add-in, though right now I'm using Qt Creator to open it.

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

          Hi, not sure, but you could always try inserting

          CONFIG += c++11
          

          in your project's .pro file.

          ZueukZ 1 Reply Last reply
          0
          • hskoglundH hskoglund

            Hi, not sure, but you could always try inserting

            CONFIG += c++11
            

            in your project's .pro file.

            ZueukZ Offline
            ZueukZ Offline
            Zueuk
            wrote on last edited by
            #5

            @hskoglund said in Qt 5.10 tries to compile my precompiled headers as C instead of C++, obviously fails:

            Hi, not sure, but you could always try inserting

            CONFIG += c++11
            

            in your project's .pro file.

            Didn't help.

            jsulmJ 1 Reply Last reply
            0
            • ZueukZ Zueuk

              @hskoglund said in Qt 5.10 tries to compile my precompiled headers as C instead of C++, obviously fails:

              Hi, not sure, but you could always try inserting

              CONFIG += c++11
              

              in your project's .pro file.

              Didn't help.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Zueuk Can you show the pro file?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              ZueukZ 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Zueuk Can you show the pro file?

                ZueukZ Offline
                ZueukZ Offline
                Zueuk
                wrote on last edited by
                #7

                @jsulm I just generated an empty Qt GUI project with precompiled headers using the current Visual Studio Tools, and it has exactly the same problem.
                By the way it did not compile in VS2017 at all - did not even give any error messages.

                Then I exported it to a .pro file

                # ----------------------------------------------------
                # This file is generated by the Qt Visual Studio Tools.
                # ------------------------------------------------------
                
                TEMPLATE = app
                TARGET = QtGuiApplication1
                DESTDIR = ../x64/Debug
                QT += core widgets gui
                CONFIG += debug
                DEFINES += _UNICODE WIN64 QT_DLL QT_WIDGETS_LIB
                INCLUDEPATH += ./GeneratedFiles \
                    . \
                    ./GeneratedFiles/Debug
                PRECOMPILED_HEADER = stdafx.h
                DEPENDPATH += .
                MOC_DIR += ./GeneratedFiles/debug
                OBJECTS_DIR += debug
                UI_DIR += ./GeneratedFiles
                RCC_DIR += ./GeneratedFiles
                include(QtGuiApplication1.pri)
                

                and tried compiling in the Qt Creator:

                C:\Qt\Qt5.10.0\Tools\QtCreator\bin\jom.exe -f Makefile.Debug
                cl -c -Yc -Fpdebug\QtGuiApplication1_pch_c.pch -Fodebug\QtGuiApplication1_pch_c.obj -nologo -Zc:wchar_t -FS -Zc:strictStrings -Zi -MDd -W3 -w44456 -w44457 -w44458 /Fddebug\QtGuiApplication1.vc.pdb -DUNICODE -D_UNICODE -DWIN32 -DWIN64 -D_UNICODE -DWIN64 -DQT_DLL -DQT_WIDGETS_LIB -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I..\QtGuiApplication1 -I. -I..\QtGuiApplication1\GeneratedFiles -I..\QtGuiApplication1 -I..\QtGuiApplication1\GeneratedFiles\Debug -IC:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include -IC:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtWidgets -IC:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtGui -IC:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtANGLE -IC:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore -IGeneratedFiles\debug -IGeneratedFiles -I\include -IC:\Qt\Qt5.10.0\5.10.0\msvc2017_64\mkspecs\win32-msvc -TC ..\QtGuiApplication1\stdafx.h
                stdafx.h
                C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(53): error C2143: syntax error: missing '{' before '*'
                C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(68): error C2061: syntax error: identifier 'Qt'
                C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(68): error C2059: syntax error: ';'
                C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(68): error C2449: found '{' at file scope (missing function header?)
                C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(1760): error C2059: syntax error: '}'
                C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(1793): error C2054: expected '(' to follow 'class'
                C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(1793): error C2085: 'QInternal': not in formal parameter list
                C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qnamespace.h(1793): error C2143: syntax error: missing ';' before '{'
                C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qsize.h(52): error C2054: expected '(' to follow 'class'
                C:\Qt\Qt5.10.0\5.10.0\msvc2017_64\include\QtCore/qsize.h(53): error C2085: 'QSize': not in formal parameter list
                etc, etc...

                I dont get these errors if I rename the "stdafx.h" file to "stdafx.hpp", but that doesn't seem to be a valid answer to the problem.

                1 Reply Last reply
                0

                • Login

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