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

300 Views Asked by At

the 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 this 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

will have got generated successfully,so my question is :

How to tell MOC to exclude gcc related includes when using CMake to compile QT app in linux?
1

There are 1 best solutions below

0
textshell On

moc is supposed to find system headers, so you should not remove these paths. This seems to be an case of https://bugreports.qt.io/browse/QTBUG-83160

Until that is fixed, or better understood, the following might be a work around:

In my case adding

#include <iso646>

as the first included header worked for me.