Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

mingw

qt

qt5

qtgui

Porting my project from Qt4 to Qt5.1, I get this error from a 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 is the chain of 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. Should I include it, even if in the original Qt4 project nothing related to OpenGL was used?

Platform:
Windows 7
MinGW 4.8
Qt 4.8 --> Qt 5.1

like image 740
Pietro Avatar asked Dec 09 '22 13:12

Pietro


1 Answers

Besides the bug in MinGW 4.8.1 with uint64_t in io.h, there is also this one in QT 5.2.1 still. I came across this today when trying to compile QT 5.2.1 with MinGW 4.8.1, so I thought I would post my solution as well.

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

in src/gui/opengl/qopengl.h line 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 there:

// Windows always needs this to ensure that APIENTRY gets defined
#if defined(Q_OS_WIN)
# include <QtCore/qt_windows.h>
# undef MemoryBarrier
#endif
like image 153
Brian Onn Avatar answered Dec 28 '22 07:12

Brian Onn