Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
nyckmaia opened this issue Feb 18, 2021 · 4 comments
Closed

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

nyckmaia opened this issue Feb 18, 2021 · 4 comments

Comments

@nyckmaia
Copy link

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
@karzhenkov
Copy link
Contributor

The error on Mac OSX looks somewhat strange. But you can #include <QFloat16> in your dialog.h (before the "hack") to make qfloat16 a complete type.

@nlohmann
Copy link
Owner

@nyckmaia Did you have the chance to try the proposal of @karzhenkov ?

@nyckmaia
Copy link
Author

Sorry @nlohmann ...not yet.

I switch my job to another company and I don't have access to this code anymore...
If you want to close this issue...ok!

@dfaure-kdab
Copy link

dfaure-kdab commented Jan 13, 2022

I had the same issue, moc file in a qt6 project not compiling because qfloat16 is an incomplete type, even though the app code doesn't use qfloat16 anywhere. #include in the headers which lead to this error indeed works around the problem, but it feels like a dirty hack...

This looks like a Qt bug though, see the comment in qdatastream.h:

src/corelib/serialization/qdatastream.h:181: // ### Qt 7: remove the operator or make qfloat16 fully defined, see QTBUG-93499
src/corelib/serialization/qdatastream.h:182: QDataStream &operator<<(qfloat16 f);

=> see https://bugreports.qt.io/browse/QTBUG-93499

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants