Details
-
Bug
-
Resolution: Duplicate
-
Not Evaluated
-
None
-
6.2.2
-
None
-
llvm clang
Description
im a bit surprised that the qt header files
have *.h file extensions, not *.hpp file extensions.
*.h = C language
*.hpp = C++ language (qt is obviously written in C++ ...)
the problem with *.h file extensions is:
when included with ...
// test.hpp
#include <qglobal.h>
... then llvm-clang will treat such files as c files (not cpp files)
to reproduce the clang error:
echo '#include <type_traits>' >test.h # wrong file extension, should be hh/hpp/hxx echo '#include "test.h"' >test.hpp # cpp wrapper file for c header # error with clang clang -c test.hpp # -> fatal error: 'type_traits' file not found # works with gcc gcc -c test.hpp
google will find some threads on this error,
most say "update your toolchain" ("update your NDK")
background: pyside, shiboken
im trying to compile pyside6, but i get this build error:
# export QT_LOGGING_RULES="*.debug=true" (core) clang_parseTranslationUnit2(0x0, cmd[13]= -isystem... -fPIC -W... -std=c++17 -I... /build/QtCore_global_lldrCF.hpp -D... ) /nix/store/0kb2vf3qnvd0cccgn6g98w4lyy7kadh7-qtbase-6.2.2-dev/include/QtCore/qglobal.h:45:12: fatal error: 'type_traits' file not found
workaround: force language to C++ by adding "-x c++" to the clangArgs
https://code.qt.io/cgit/pyside/shiboken.git/tree/ApiExtractor/apiextractor.cpp#n276
// apiextractor.cpp // line ~200 QStringLiteral("_XXXXXX.hpp"); // ... arguments.append(QByteArrayLiteral("-x")); arguments.append(QByteArrayLiteral("c++")); arguments.append(QFile::encodeName(preprocessedCppFileName));
radical solution: rename header files from *.h to *.hpp
(principle of least surprise)
Attachments
Issue Links
- duplicates
-
PYSIDE-787 Building with clang doesn't work when Qt headers are in a system header location
- Closed