Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. How to tell MOC to exclude gcc related includes to avoid problem like:Parse error at "std"?

How to tell MOC to exclude gcc related includes to avoid problem like:Parse error at "std"?

Scheduled Pinned Locked Moved Unsolved C++ Gurus
3 Posts 2 Posters 756 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.
  • A Offline
    A Offline
    Alex Luya
    wrote on last edited by
    #1

    Hello,below moc statement: :

    /usr/lib/qt5/bin/moc -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 "-DvtkRenderingCore_AUTOINIT_INCLUDE=\"/home/alex/workspace/MTESS/build/CMakeFiles/vtkModuleAutoInit_be7301261a49b13d6a9b1d9e110eacd8.h\"" -I/home/alex/workspace/MTESS/src -I/home/alex/workspace/MTESS/vendor/ProjectStructure -I/home/alex/workspace/MTESS/vendor/imgui -I/home/alex/workspace/MTESS/vendor/imgui/imgui -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/local/qwt-6.2.0/include -I/usr/local/include/opencascade -I/lib -I/usr/local/include -I/usr/include/c++/11 -I/usr/include/x86_64-linux-gnu/c++/11 -I/usr/include/c++/11/backward -I/usr/lib/llvm-14/lib/clang/14.0.0/include -I/usr/include/x86_64-linux-gnu -I/usr/include --include /home/alex/workspace/MTESS/build/MTESS_autogen/moc_predefs.h --output-dep-file -o /home/alex/workspace/MTESS/build/MTESS_autogen/MLM4FWGUYC/moc_NearFieldProcessUtil.cpp /home/alex/workspace/MTESS/src/Layers/ViewLayer/Process/NearFieldProcessUtil.h
    

    will give error :

    usr/include/c++/11/bits/fs_fwd.:39: Parse error at "std"
    

    If removing:

    -I/usr/local/include -I/usr/include/c++/11 -I/usr/include/x86_64-linux-gnu/c++/11 -I/usr/include/c++/11/backward
    

    from above statement,then run:

    /usr/lib/qt5/bin/moc -DJSON_DIAGNOSTICS=0 -DJSON_USE_IMPLICIT_CONVERSIONS=1 "-DvtkRenderingCore_AUTOINIT_INCLUDE=\"/home/alex/workspace/MTESS/build/CMakeFiles/vtkModuleAutoInit_be7301261a49b13d6a9b1d9e110eacd8.h\"" -I/home/alex/workspace/MTESS/src -I/home/alex/workspace/MTESS/vendor/ProjectStructure -I/home/alex/workspace/MTESS/vendor/imgui -I/home/alex/workspace/MTESS/vendor/imgui/imgui -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/local/qwt-6.2.0/include -I/usr/local/include/opencascade -I/lib -I/usr/lib/llvm-14/lib/clang/14.0.0/include -I/usr/include/x86_64-linux-gnu -I/usr/include --include /home/alex/workspace/MTESS/build/MTESS_autogen/moc_predefs.h --output-dep-file -o /home/alex/workspace/MTESS/build/MTESS_autogen/MLM4FWGUYC/moc_NearFieldProcessUtil.cpp /home/alex/workspace/MTESS/src/Layers/ViewLayer/Process/NearFieldProcessUtil.h
    

    The expected file:

    moc_NearFieldProcessUtil.cpp
    

    got generated successfully,so my question is :

    When using CMake to compile QT app in linux,How to tell MOC to exclude gcc related includes?
    
    1 Reply Last reply
    0
    • jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by jeremy_k
      #2

      From the very end of the Command-Line Options section:

      You can explicitly tell the moc not to parse parts of a header file. moc defines the preprocessor symbol Q_MOC_RUN. Any code surrounded by

      #ifndef Q_MOC_RUN
          ...
      #endif
      

      is skipped by the moc.

      Asking a question about code? http://eel.is/iso-c++/testcase/

      A 1 Reply Last reply
      1
      • jeremy_kJ jeremy_k

        From the very end of the Command-Line Options section:

        You can explicitly tell the moc not to parse parts of a header file. moc defines the preprocessor symbol Q_MOC_RUN. Any code surrounded by

        #ifndef Q_MOC_RUN
            ...
        #endif
        

        is skipped by the moc.

        A Offline
        A Offline
        Alex Luya
        wrote on last edited by
        #3

        @jeremy_k Thanks,I want to exclude all gcc headers which is not created by myself,but comes from GCC.

        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