QTypeInfo error on GCC
-
Hi everyone.
I have a problem while cross compiling a project originally created and compiled on Windows (MSVS 2019), on CentOS 8 with GCC.The errors I have are:
/Qt5.9.6/5.9.6/gcc_64/include/QtCore/qtypeinfo.h:246: error: specialization of ‘template<class T> class QTypeInfo’ in different namespace [-fpermissive] class QTypeInfo<TYPE > \ ^~~~~~~~~~~~~~~~ Qt5.9.6/5.9.6/gcc_64/include/QtCore/qtypeinfo.h:246: error: explicit specialization of ‘template<class T> class QTypeInfo’ outside its namespace must use a nested-name-specifier [-fpermissive] class QTypeInfo<TYPE > \ ^~~~~~~~~~~~~~~~ /Qt5.9.6/5.9.6/gcc_64/include/QtCore/qtypeinfo.h:254: error: invalid application of ‘sizeof’ to incomplete type ‘QPoint’ isLarge = (sizeof(TYPE)>sizeof(void*)), \ ^
I what can cause the issue in GCC but not in MSVS?
-
Hi everyone.
I have a problem while cross compiling a project originally created and compiled on Windows (MSVS 2019), on CentOS 8 with GCC.The errors I have are:
/Qt5.9.6/5.9.6/gcc_64/include/QtCore/qtypeinfo.h:246: error: specialization of ‘template<class T> class QTypeInfo’ in different namespace [-fpermissive] class QTypeInfo<TYPE > \ ^~~~~~~~~~~~~~~~ Qt5.9.6/5.9.6/gcc_64/include/QtCore/qtypeinfo.h:246: error: explicit specialization of ‘template<class T> class QTypeInfo’ outside its namespace must use a nested-name-specifier [-fpermissive] class QTypeInfo<TYPE > \ ^~~~~~~~~~~~~~~~ /Qt5.9.6/5.9.6/gcc_64/include/QtCore/qtypeinfo.h:254: error: invalid application of ‘sizeof’ to incomplete type ‘QPoint’ isLarge = (sizeof(TYPE)>sizeof(void*)), \ ^
I what can cause the issue in GCC but not in MSVS?
-
Hi
What version of GCC ?
the "in different namespace " reminded me of something
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480
You say
- while cross compiling a project
well it's just compiling right?
as normally cross compiling implies that you try to generate an executable on other platform.
Like cross compiling in Linux for/to windows. -
Then msvc allows a C++ construct but gcc8 does not. Fix your code.
-
@Xumepoc
When you get these errors, referring to something in a header file, do you not also get a line number in a file of your own code where the error is coming from? I'm not as knowledgable as @Christian-Ehrlicher, but I'm not understanding whether you get these errors just when the.h
file is read or whether you get them from your own code trying to use something from the .h
file? -
@Xumepoc You compile the source code so you know which file triggers the error.
-
@JonB I get the errors in qtypeinfo.h
/gcc_64/include/QtCore/qtypeinfo.h:265: error: specialization of ‘template<class T> class QTypeInfo’ in different namespace [-fpermissive] class QTypeInfo<TYPE > \ ^~~~~~~~~~~~~~~~ /gcc_64/include/QtCore/qtypeinfo.h:265: error: explicit specialization of ‘template<class T> class QTypeInfo’ outside its namespace must use a nested-name-specifier [-fpermissive] class QTypeInfo<TYPE > \ ^~~~~~~~~~~~~~~~
and in type_traits
/usr/include/c++/8/type_traits:661: error: invalid use of incomplete type ‘class QPoint’ struct is_trivial ^~~~~~~~~~
I don't get any errors in my code.
@Christian-Ehrlicher I did not compile the source code, this is 5.14.2 installed through the installer.
-
@JonB I get the errors in qtypeinfo.h
/gcc_64/include/QtCore/qtypeinfo.h:265: error: specialization of ‘template<class T> class QTypeInfo’ in different namespace [-fpermissive] class QTypeInfo<TYPE > \ ^~~~~~~~~~~~~~~~ /gcc_64/include/QtCore/qtypeinfo.h:265: error: explicit specialization of ‘template<class T> class QTypeInfo’ outside its namespace must use a nested-name-specifier [-fpermissive] class QTypeInfo<TYPE > \ ^~~~~~~~~~~~~~~~
and in type_traits
/usr/include/c++/8/type_traits:661: error: invalid use of incomplete type ‘class QPoint’ struct is_trivial ^~~~~~~~~~
I don't get any errors in my code.
@Christian-Ehrlicher I did not compile the source code, this is 5.14.2 installed through the installer.
@Xumepoc said in QTypeInfo error on GCC:
@Christian-Ehrlicher I did not compile the source code, this is 5.14.2 installed through the installer.
I never said this.
You're trying to compile some code. This code triggers a warning inside the Qt headers. So simplify your code until the error is no longer triggered and the fix your code.
-
Yes, that would be a solution, if the project was started in Linux and complied with GCC. But as I said in my previous post, this project was originally written in Windows and compiled with MSVS where that error does not occurs. So I am not sure at what step during the development phase of the project the effect would appear if it was compiled with GCC in the first place.
-
Hi,
In that case, keep only a bare main.cpp file and gradually add back your other files until it breaks.
-
Have you not considered using a newer version of GCC? I'm not sure on the specifics on the changes between 8 and 11 (for example), but it would be worth a shot, considering I have never had an issue in Qt triggered by a fault in GCC (which is the compiler I have Qt set to use).
sudo yum groupinstall "Development Tools"
? -
Yes, that would be a solution, if the project was started in Linux and complied with GCC. But as I said in my previous post, this project was originally written in Windows and compiled with MSVS where that error does not occurs. So I am not sure at what step during the development phase of the project the effect would appear if it was compiled with GCC in the first place.
@Xumepoc Again: you compile a your source files on linux. So look which source file generates the error and strip it down until it no longer occurs - daily programmers business.
-
@Christian-Ehrlicher I didn't expect anyone to debug my code, just if someone had encountered the same issues or have some guidance.
-
@Christian-Ehrlicher I didn't expect anyone to debug my code, just if someone had encountered the same issues or have some guidance.
@Xumepoc said in QTypeInfo error on GCC:
or have some guidance.
We have (and told you already a lot of times) - take a look from where the error comes from and fix it.
-
@Christian-Ehrlicher I didn't expect anyone to debug my code, just if someone had encountered the same issues or have some guidance.
@Xumepoc
I did ask you earlier where from your own code does the#include
which leads to this error appear, but never got an answer.Never mind. I believe/suggest you might find your situation is reported on this forum in Q_DECLARE_TYPEINFO and namespaces - how does it work? from 2012? I suggest you read there. The final post indicates to me there is a change which will allow your code to compile under GCC as well as MSVC:
Case 2: I did forget the semicolon after the Q_DECLARE_TYPEINFO. This case now works on both compilers. Thanks!