Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
None
-
5.15.1
-
-
d3ed7dac8aa2f4ede0c409254b9dd44842086be0 (qt/qtbase/dev) 9022eab63a1df149afc642c0eea03f6e548330b2 (qt/qtbase/5.15)
Description
OS: Linuxmint 20 ulyana amd64
Qt5.15.1 compiled from source with the configuration command
./configure -prefix /opt/Qt5.15.1 -gstreamer
When compiling a simple project using Qt and Bsoncxx 3.4.3 (from the C++ Mongocxx 3.4.3 driver for working with MongoDB) an error is displayed:
AutoMoc subprocess error ------------------------ The moc process failed to compile "SRC:/test.h" into "BIN:/bsoncxx_qt_bug_test_autogen/EWIEGA46WW/moc_test.cpp" Command ------- /opt/Qt5.15.1/bin/moc -DQT_CORE_LIB -DQT_NO_DEBUG -I/home/rumgot/build-bsoncxx_qt_bug_test-Desktop_5_15_1-Release -I/home/rumgot/bsoncxx_qt_bug_test -I/usr/local/include/mongocxx/v_noabi -I/usr/local/include/bsoncxx/v_noabi -I/opt/Qt5.15.1/include -I/opt/Qt5.15.1/include/QtCore -I/opt/Qt5.15.1/mkspecs/linux-g++ -I/usr/include/c++/9 -I/usr/include/x86_64-linux-gnu/c++/9 -I/usr/include/c++/9/backward -I/usr/lib/gcc/x86_64-linux-gnu/9/include -I/usr/local/include -I/usr/include/x86_64-linux-gnu -I/usr/include --include /home/rumgot/build-bsoncxx_qt_bug_test-Desktop_5_15_1-Release/bsoncxx_qt_bug_test_autogen/moc_predefs.h -p ./ -o /home/rumgot/build-bsoncxx_qt_bug_test-Desktop_5_15_1-Release/bsoncxx_qt_bug_test_autogen/EWIEGA46WW/moc_test.cpp /home/rumgot/bsoncxx_qt_bug_test/test.h Output ------ usr/local/include/bsoncxx/v_noabi/bsoncxx/types.hp:41: Parse error at "/usr/local/include/bsoncxx/v_noabi/bsoncxx/enums/type.hpp" make[2]: *** [CMakeFiles/bsoncxx_qt_bug_test_autogen.dir/build.make:58: CMakeFiles/bsoncxx_qt_bug_test_autogen] Error 1 make[1]: *** [CMakeFiles/Makefile2:104: CMakeFiles/bsoncxx_qt_bug_test_autogen.dir/all] Error 2 make: *** [Makefile:84: all] Error 2
/usr/local/include/bsoncxx/v_noabi/bsoncxx/types.hpp file fragment
enum class type : std::uint8_t { #define BSONCXX_ENUM(name, val) k_##name = val, #include <bsoncxx/enums/type.hpp> #undef BSONCXX_ENUM };
/usr/local/include/bsoncxx/v_noabi/bsoncxx/enums/type.hpp file fragment
#ifndef BSONCXX_ENUM #error "This header is only meant to be included as an X-macro over BSONCXX_ENUM" #endif BSONCXX_ENUM(double, 0x01) BSONCXX_ENUM(utf8, 0x02) BSONCXX_ENUM(document, 0x03) BSONCXX_ENUM(array, 0x04) BSONCXX_ENUM(binary, 0x05) BSONCXX_ENUM(undefined, 0x06) BSONCXX_ENUM(oid, 0x07) BSONCXX_ENUM(bool, 0x08) BSONCXX_ENUM(date, 0x09) BSONCXX_ENUM(null, 0x0A) BSONCXX_ENUM(regex, 0x0B) BSONCXX_ENUM(dbpointer, 0x0C) BSONCXX_ENUM(code, 0x0D) BSONCXX_ENUM(symbol, 0x0E) BSONCXX_ENUM(codewscope, 0x0F) BSONCXX_ENUM(int32, 0x10) BSONCXX_ENUM(timestamp, 0x11) BSONCXX_ENUM(int64, 0x12) BSONCXX_ENUM(decimal128, 0x13) BSONCXX_ENUM(maxkey, 0x7F) BSONCXX_ENUM(minkey, 0xFF)
Here is a small project to reproduce the bug
CMakeLists.txt
cmake_minimum_required(VERSION 3.14) project(bsoncxx_qt_bug_test LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) find_package(Qt5Core) find_package(libmongocxx REQUIRED) add_executable(bsoncxx_qt_bug_test main.cpp test.cpp test.h ) target_link_libraries(bsoncxx_qt_bug_test Qt5::Core) target_link_libraries(bsoncxx_qt_bug_test ${LIBMONGOCXX_LIBRARIES} Qt5::Core) target_include_directories(bsoncxx_qt_bug_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(bsoncxx_qt_bug_test PUBLIC ${LIBMONGOCXX_INCLUDE_DIRS}) target_compile_definitions(bsoncxx_qt_bug_test PRIVATE ${LIBMONGOCXX_DEFINITIONS})
main.cpp
#include "test.h" #include <QCoreApplication> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); return a.exec(); }
test.h
#ifndef TEST_H #define TEST_H #include <QObject> #include <bsoncxx/types.hpp> class Test : public QObject { Q_OBJECT public: explicit Test(QObject *parent = nullptr); signals: }; #endif // TEST_H
test.cpp
#include "test.h"
Test::Test(QObject *parent) : QObject(parent) {}
In Qt5.12.9, this code compiles correctly and without errors!
Update 0:
If you wrap all the include directives to include the bsoncxx/mongocxx header files in blocks
#ifndef Q_MOC_RUN // start to include the bsoncxx/mongocxx library header files #include <bsoncxx/types.hpp> #include <bsoncxx/array/value.hpp> #include <bsoncxx/array/view.hpp> #include <bsoncxx/builder/stream/document.hpp> #include <bsoncxx/document/value.hpp> #include <bsoncxx/document/view.hpp> // etc #endif
then the compilation is successful.
Attachments
Issue Links
- is duplicated by
-
QTBUG-93950 moc parse error on combination of namespace, enum and include
- Closed
- relates to
-
QTBUG-101466 Moc tool removes enum keyword from namespaces
- Reported