Skip to content

error: incomplete type 'qfloat16' used in type trait expression #2650

@nyckmaia

Description

@nyckmaia

Hi, I compiled without errors or warnings my C++ code in Windows and Linux, but when tried to compile it on Mac OSX, I got this compile-time error below?

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:2803: error: incomplete type 'qfloat16' used in type trait expression
In file included from Lobular-Bearing-Plugin_autogen/mocs_compilation.cpp:2:
In file included from Lobular-Bearing-Plugin_autogen/D4ILV6QMEK/moc_table.cpp:9:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:652:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:2803:38: error: incomplete type 'qfloat16' used in type trait expression
    : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
                                     ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/type_traits:2821:14: note: in instantiation of template class 'std::__1::is_constructible<qfloat16>' requested here
    : public is_constructible<_Tp>
             ^
/Users/nyckstudio/Downloads/lobular-bearing-plugin/include/nlohmann/json.hpp:2727:10: note: in instantiation of template class 'std::__1::is_default_constructible<qfloat16>' requested here
    std::is_default_constructible<ConstructibleArrayType>::value and
         ^
/Users/nyckstudio/Downloads/lobular-bearing-plugin/include/nlohmann/json.hpp:2753:7: note: during template argument deduction for class template partial specialization 'is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType, enable_if_t<!std::is_same<ConstructibleArrayType, typename BasicJsonType::value_type>::value && std::is_default_constructible<ConstructibleArrayType>::value && (std::is_move_assignable<ConstructibleArrayType>::value || std::is_copy_assignable<ConstructibleArrayType>::value) && is_detected<value_type_t, ConstructibleArrayType>::value && is_detected<iterator_t, ConstructibleArrayType>::value && is_complete_type<detected_t<value_type_t, ConstructibleArrayType> >::value> >' [with BasicJsonType = nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long, unsigned long long, double, std::allocator, adl_serializer>, ConstructibleArrayType = qfloat16]
    : is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {};
      ^
/Users/nyckstudio/Downloads/lobular-bearing-plugin/include/nlohmann/json.hpp:2753:7: note: in instantiation of template class 'nlohmann::detail::is_constructible_array_type_impl<nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long, unsigned long long, double, std::allocator, adl_serializer>, qfloat16, void>' requested here
/Users/nyckstudio/Downloads/lobular-bearing-plugin/include/nlohmann/json.hpp:3099:15: note: in instantiation of template class 'nlohmann::detail::is_constructible_array_type<nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long, unsigned long long, double, std::allocator, adl_serializer>, qfloat16>' requested here
              is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value and
              ^
/Users/nyckstudio/Downloads/lobular-bearing-plugin/include/nlohmann/json.hpp:3105:6: note: (skipping 21 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all)
auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
     ^
/Users/nyckstudio/Qt/6.0.1/clang_64/lib/QtCore.framework/Headers/qmetatype.h:2165:42: note: in instantiation of variable template specialization 'QTypeTraits::has_stream_operator_v<QDataStream, nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long, unsigned long long, double, std::allocator, adl_serializer> >' requested here
template<typename T, bool = QTypeTraits::has_stream_operator_v<QDataStream, T>>
                                         ^
/Users/nyckstudio/Qt/6.0.1/clang_64/lib/QtCore.framework/Headers/qmetatype.h:2265:29: note: in instantiation of default argument for 'QDataStreamOperatorForType<nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long, unsigned long long, double, std::allocator, adl_serializer> >' required here
        /*.dataStreamOut=*/ QDataStreamOperatorForType<T>::dataStreamOut,
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/nyckstudio/Qt/6.0.1/clang_64/lib/QtCore.framework/Headers/qmetatype.h:2377:48: note: in instantiation of static data member 'QtPrivate::QMetaTypeInterfaceWrapper<nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long, unsigned long long, double, std::allocator, adl_serializer> >::metaType' requested here
        return &QMetaTypeInterfaceWrapper<Ty>::metaType;
                                               ^
/Users/nyckstudio/Qt/6.0.1/clang_64/lib/QtCore.framework/Headers/qmetatype.h:2421:16: note: in instantiation of function template specialization 'QtPrivate::qTryMetaTypeInterfaceForType<qt_meta_stringdata_Dialog_t, QtPrivate::TypeAndForceComplete<nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long, unsigned long long, double, std::allocator, adl_serializer> &, std::__1::integral_constant<bool, false> > >' requested here
    QtPrivate::qTryMetaTypeInterfaceForType<Unique, T>()...
               ^
Lobular-Bearing-Plugin_autogen/6YEA5652QU/moc_dialog.cpp:111:1: note: in instantiation of variable template specialization 'qt_incomplete_metaTypeArray<qt_meta_stringdata_Dialog_t, QtPrivate::TypeAndForceComplete<void, std::__1::integral_constant<bool, false> >, QtPrivate::TypeAndForceComplete<nlohmann::basic_json<std::map, std::vector, std::__1::basic_string<char>, bool, long long, unsigned long long, double, std::allocator, adl_serializer> &, std::__1::integral_constant<bool, false> >, QtPrivate::TypeAndForceComplete<int, std::__1::integral_constant<bool, false> >, QtPrivate::TypeAndForceComplete<void, std::__1::integral_constant<bool, false> >, QtPrivate::TypeAndForceComplete<void, std::__1::integral_constant<bool, false> >, QtPrivate::TypeAndForceComplete<void, std::__1::integral_constant<bool, false> > >' requested here
qt_incomplete_metaTypeArray<qt_meta_stringdata_Dialog_t
^
/Users/nyckstudio/Qt/6.0.1/clang_64/lib/QtCore.framework/Headers/qdatastream.h:54:7: note: forward declaration of 'qfloat16'
class qfloat16;
      ^

The header that I'm using is from @karzhenkov, called: nlohmann_json_qt6_hack.h
nlohmann_json_qt6_hack.h
See Issue #2519

How can I fix it?

  • Compiler: clang 9.3
  • OS: MacOS Catalina 10.15.7 x64
  • Qt 6.0.1
  • Qt Creator IDE 4.14.0
  • latest release version 3.9.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions