I've been doing some tests to try to use LLVM to build a big 20 year old project developed with GCC.
Among the vast number of issues one of the problems is with old Qt headers. We're building with -std=c++14 and get many errors like
src/gui/QT4/core/grapp/src/bkmrk:205:34: error: no matching literal operator for call to 'operator""__FILE__' with arguments of types 'const char *' and 'unsigned long', and no matching literal operator template
205 | connect (dAddBookMarkAction, SIGNAL(triggered()),
| ^
/path/to/include/QtCore/qobjectdefs.h:203:42: note: expanded from macro 'SIGNAL'
203 | # define SIGNAL(a) qFlagLocation("2"#a QLOCATION)
| ^
/path/to/include/QtCore/qobjectdefs.h:200:24: note: expanded from macro 'QLOCATION'
200 | # define QLOCATION "\0"__FILE__":"QTOSTRING(__LINE__)
As is often the case, GCC being laxer than LLVM compiles this without warning.
Is there any option that will turn off literal operators? I haven't seen any in the LLVM doc.
Other possible fixes:
- edit the Qt headers and insert a space between the closing double quote and the underscore of FILE. I don't have write access, so I'd prefer a simpler fix if possible.
- wrapp all includes with #if clang/pragma push options/add -std=c++11 #endif #include header #if clang/pragma pop options #endif
- add a qobjectdefs.h that #include_nexts the dodgy qobjectdefs.h and then #undefs and #defines the dodgy macros