Compile-time error from Qt file: expected unqualified identifier before ')' token

Porting my project from Qt4 to Qt5.1, I get this error from the Qt file:

C:\Qt\Qt5.1.1\5.1.1\mingw48_32\include\QtGui\qopenglversionfunctions.h:785: error: expected unqualified-id before ')' token void (QOPENGLF_APIENTRYP MemoryBarrier)(GLbitfield barriers); ^ 

This chain defines:

 #define QOPENGLF_APIENTRYP QOPENGLF_APIENTRY * #define QOPENGLF_APIENTRY APIENTRY #define APIENTRY WINAPI #define WINAPI __stdcall 

I noticed that the "MemoryBarrier" token is present in the libQt5OpenGLExtensionsd.a library. Do I have to include it even if nothing was related to OpenGL in the original Qt4 project?

Platform:
Windows 7
MinGW 4.8
Qt 4.8 β†’ Qt 5.1

+4
source share
4 answers

I noticed that the "MemoryBarrier" token is present in the libQt5OpenGLExtensionsd.a library. Should I include it even if nothing in OpenGL's original Qt4 project?

No, it is not connected. OpenGLExtension compiles after QtGui.

Unfortunately, you are attacking that MemoryBarrier () is already installed on Windows, and therefore there is a conflict for this and what qt is. To do this, you can find the official Windows documentation:

http://msdn.microsoft.com/en-us/library/windows/apps/ms684208(v=vs.85).aspx

I just discussed this with Gunnar, the QtGui developer, and I plan to submit the changes to Gerrit to solve your problem.

We used something similar in our project a couple of years ago when we wrote thread-safe QtCore-based singletones:

 #if defined __GNUC__ && __GNUC__ >= 4 && __GNUC_MINOR__ >= 4 #define __MEMBARRIER __sync_synchronize(); #elif defined _MSC_VER && defined _WIN64 #define __MEMBARRIER MemoryBarrier(); #else #define __MEMBARRIER #endif 

Qt may need to check ifdef MINGW / GCC / VERSION and determine the value of MemoryBarrier.

EDIT: This was fixed about six months ago. For more information, see the following Gerrit overview and related error report:

https://codereview.qt-project.org/#change,68156

and

https://bugreports.qt.io/browse/QTBUG-34080

So upgrade to Qt 5.2.0 and it will work. Otherwise, you may try to back up.

+5
source

Besides the error in MinGW 4.8.1 with uint64_t in io.h , it is also in QT 5.2.1. I came across this today when trying to compile QT 5.2.1 with MinGW 4.8.1, so I thought I would also post my solution.

I don’t know what the official fix will be for QT, but for my needs I did it like this:

at line src / gui / opengl / qopengl.h 49:

 // Windows always needs this to ensure that APIENTRY gets defined #if defined(Q_OS_WIN) # include <QtCore/qt_windows.h> #endif 

I just undefined the Windows MemoryBarrier macro:

 // Windows always needs this to ensure that APIENTRY gets defined #if defined(Q_OS_WIN) # include <QtCore/qt_windows.h> # undef MemoryBarrier #endif 
+7
source

I am facing the same problem. I could compile and run just by commenting out the problem line:

 // void (QOPENGLF_APIENTRYP MemoryBarrier)(GLbitfield barriers); 

In file C: /Qt/Qt5.1.1/5.1.1/mingw48_32/include/QtGui/qopenglversionfunctions.h: 785

My application does not use any OpenGL files. Let them hope they fix it soon; -)

+1
source

Since the accepted answer does not seem to help when someone is trying to create a QT library on it, and Laszlo Pap claims that another solution is not the right solution, I tried to find a way to fix it correctly. I found wiring on Google where it was said that the MemoryBarrier not implemented in MingW, and there was a patch for it.

So I tried to include the patch in opengl.h and hope this is the right way, as simply commenting out the lines can cause problems later.

 #ifndef QT_NO_OPENGL // Windows always needs this to ensure that APIENTRY gets defined #if defined(Q_OS_WIN) # include <QtCore/qt_windows.h> #if defined(__MINGW32__) && defined(MemoryBarrier) #undef MemoryBarrier __CRT_INLINE void MemoryBarrier(void) { long Barrier = 0; __asm__ __volatile__("xchgl %%eax,%0 " :"=r" (Barrier)); } #endif #endif 
+1
source

Source: https://habr.com/ru/post/1501638/


All Articles