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. Precompiled header for c++ project with a .c file [linux]
Servers for Qt installer are currently down

Precompiled header for c++ project with a .c file [linux]

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 556 Views
  • 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.
  • M Offline
    M Offline
    Mwoua
    wrote on 30 Mar 2018, 17:42 last edited by
    #1

    Hello,
    I have a c++ project with precompiled header (stdafx.h) that compile fine. However, after adding a .c file to my project, it fails at compiling stdafx on

    #include <map>
    

    The new .c /.h files are completely independant from the other files, i.e. there is no include at all (beside <stdlib.h>) but it still try to build stdafx for a c project.

    The command from console log without the .c file :

    g++ -pipe -DQT_COMPILING_QSTRING_COMPAT_CPP -Wsuggest-override -Werror=suggest-override -isystem "/opt/Qt5.7.1/5.7/gcc_64/include/QtCore" -isystem "/opt/Qt5.7.1/5.7/gcc_64/include/QtWidgets" -isystem "/opt/Qt5.7.1/5.7/gcc_64/include/QtSerialport" -isystem "/opt/Qt5.7.1/5.7/gcc_64/include/QtTestlib" -isystem /opt/Qt5.7.1/5.7/gcc_64/include/qt5 -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DTEST_LIBRARY -DQT_USE_QSTRINGBUILDER -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_SERIALPORT_LIB -DQT_TESTLIB_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR='"/home/dlevy/Perforce/dlevy_Builder04_LC3.3_main/Qt/main/Test"' -I. -I../TestTech -I../Common -I../Ltp_Production -I../LC4/main/src -I../LC4/main/src/Test -I../LC4/main/src/TestPrototypes -I../LC4/main/src/TestPrivate -I../LC4/main/src/TestTech -I../LC4/main/src/shared -I../LC4/main/src/shared/comm -I/opt/Qt5.7.1/5.7/gcc_64/include -I/opt/Qt5.7.1/5.7/gcc_64/include/QtWidgets -I/opt/Qt5.7.1/5.7/gcc_64/include/QtGui -I/opt/Qt5.7.1/5.7/gcc_64/include/QtSerialPort -I/opt/Qt5.7.1/5.7/gcc_64/include/QtTest -I/opt/Qt5.7.1/5.7/gcc_64/include/QtCore -IRelease -I/opt/Qt5.7.1/5.7/gcc_64/mkspecs/linux-g++ -x c++-header -c StdAfx.h -o Release/Test.gch/c++
    

    and with the .c file :

    gcc -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DTEST_LIBRARY -DQT_USE_QSTRINGBUILDER -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_SERIALPORT_LIB -DQT_TESTLIB_LIB -DQT_CORE_LIB -DQT_TESTCASE_BUILDDIR='"/home/dlevy/Perforce/dlevy_Builder04_LC3.3_main/Qt/main/Test"' -I. -I../TestTech -I../Common -I../Ltp_Production -I../LC4/main/src -I../LC4/main/src/Test -I../LC4/main/src/TestPrototypes -I../LC4/main/src/TestPrivate -I../LC4/main/src/TestTech -I../LC4/main/src/shared -I../LC4/main/src/shared/comm -I/opt/Qt5.7.1/5.7/gcc_64/include -I/opt/Qt5.7.1/5.7/gcc_64/include/QtWidgets -I/opt/Qt5.7.1/5.7/gcc_64/include/QtGui -I/opt/Qt5.7.1/5.7/gcc_64/include/QtSerialPort -I/opt/Qt5.7.1/5.7/gcc_64/include/QtTest -I/opt/Qt5.7.1/5.7/gcc_64/include/QtCore -IRelease -I/opt/Qt5.7.1/5.7/gcc_64/mkspecs/linux-g++ -x c-header -c StdAfx.h -o Release/Test.gch/c
    

    I noticed at the end of the command that cxx-header became c-header.

    Is there something I am not doing correctly?

    Additionnal info:
    -No problem on windows
    -The header for the .c file is surounded by extern C

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mwoua
      wrote on 30 Mar 2018, 17:56 last edited by
      #2

      After reading the doc again, I found that I need to add

      #if defined __cplusplus
      /* Add C++ includes here */
      

      in my stdafx file. There is nothing related to the .c file, but I guess the compiler parse it once for the .c file, and another time for the .cpp files.

      1 Reply Last reply
      0

      1/2

      30 Mar 2018, 17:42

      • 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