nigels-com / glew

The OpenGL Extension Wrangler Library
Other
2.67k stars 623 forks source link

definition of GLsizeiptr is inconsistent with Khronos gl32.h on armel and armhf #403

Open drew-parsons opened 11 months ago

drew-parsons commented 11 months ago

glew defines GLsizeiptr as ptrdiff_t in /usr/include/GL/glew.h, from https://github.com/nigels-com/glew/blob/e1a80a9f12d7def202d394f46e44cfced1104bfb/auto/core/gl/GL_VERSION_1_5#L74

This definition is inconsistent with the gles3.2 definition, which is

typedef khronos_ssize_t GLsizeiptr;

from https://gitlab.freedesktop.org/glvnd/libglvnd/-/blame/master/include/GLES3/gl32.h#L56

The discrepancy causes a build error on armel (gnueabi) and armhf. The problem was reported against debian packages at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=798408

It is triggered for instance by packages using QtOpenGL on armel or armhf while also accessing glew. For example, building avogadrolibs on armel gives the error

[ 97%] Building CXX object avogadro/qtplugins/cp2kinput/CMakeFiles/Cp2kInput.dir/Cp2kInputPlugin.cpp.o
cd /build/avogadrolibs-1.98.1/obj-arm-linux-gnueabi/avogadro/qtplugins/cp2kinput && /usr/bin/c++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_STATICPLUGIN -DQT_WIDGETS_LIB -I/build/avogadrolibs-1.98.1/obj-arm-linux-gnueabi/avogadro/qtplugins/cp2kinput -I/build/avogadrolibs-1.98.1/avogadro/qtplugins/cp2kinput -I/build/avogadrolibs-1.98.1/obj-arm-linux-gnueabi/avogadro/qtplugins/cp2kinput/Cp2kInput_autogen/include -I/build/avogadrolibs-1.98.1/avogadro -I/build/avogadrolibs-1.98.1/obj-arm-linux-gnueabi/avogadro -I/build/avogadrolibs-1.98.1 -I/build/avogadrolibs-1.98.1/obj-arm-linux-gnueabi -I/build/avogadrolibs-1.98.1/obj-arm-linux-gnueabi/avogadro/qtgui -I/buildavogadrolibs-1.98.1/obj-arm-linux-gnueabi/avogadro/io -I/build/avogadrolibs-1.98.1/obj-arm-linux-gnueabi/avogadro/core -I/build/avogadrolibs-1.98.1/obj-arm-linux-gnueabi/avogadro/molequeue -isystem /usr/include/eigen3 -isystem /usr/include/arm-linux-gnueabi/qt5 -isystem /usr/include/arm-linux-gnueabi/qt5/QtWidgets -isystem /usr/include/arm-linux-gnueabi/qt5/QtGui -isystem /usr/include/arm-linux-gnueabi/qt5/QtCore -isystem /usr/lib/arm-linux-gnueabi/qt5/mkspecs/linux-g++ -isystem /usr/include/arm-linux-gnueabi/qt5/QtNetwork -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -g -O2 -ffile-prefix-map=/build/avogadrolibs-1.98.1=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Wno-deprecated-declarations -std=c++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -fPIC -MD -MT avogadro/qtplugins/cp2kinput/CMakeFiles/Cp2kInput.dir/Cp2kInputPlugin.cpp.o -MF CMakeFiles/Cp2kInput.dir/Cp2kInputPlugin.cpp.o.d -o CMakeFiles/Cp2kInput.dir/Cp2kInputPlugin.cpp.o -c /build/avogadrolibs-1.98.1/obj-arm-linux-gnueabi/avogadro/qtplugins/cp2kinput/Cp2kInputPlugin.cpp
In file included from /usr/include/arm-linux-gnueabi/qt5/QtGui/qopengl.h:105,
                 from /usr/include/arm-linux-gnueabi/qt5/QtWidgets/qopenglwidget.h:49,
                 from /usr/include/arm-linux-gnueabi/qt5/QtWidgets/QOpenGLWidget:1,
                 from /build/avogadrolibs-1.98.1/avogadro/qtopengl/glwidget.h:16,
                 from /build/avogadrolibs-1.98.1/avogadro/qtplugins/overlayaxes/overlayaxes.cpp:14:
/usr/include/GLES3/gl32.h:56:25: error: conflicting declaration 'typedef khronos_ssize_t GLsizeiptr'
   56 | typedef khronos_ssize_t GLsizeiptr;
      |                         ^~~~~~~~~~
In file included from /build/avogadrolibs-1.98.1/avogadro/rendering/avogadrogl.h:15,
                 from /build/avogadrolibs-1.98.1/avogadro/qtplugins/overlayaxes/overlayaxes.cpp:8:
/usr/include/GL/glew.h:1694:19: note: previous declaration as 'typedef ptrdiff_t GLsizeiptr'
 1694 | typedef ptrdiff_t GLsizeiptr;
      |                   ^~~~~~~~~~
/usr/include/GLES3/gl32.h:57:26: error: conflicting declaration 'typedef khronos_intptr_t GLintptr'
   57 | typedef khronos_intptr_t GLintptr;
      |                          ^~~~~~~~
/usr/include/GL/glew.h:1693:19: note: previous declaration as 'typedef ptrdiff_t GLintptr'
 1693 | typedef ptrdiff_t GLintptr;
      |                   ^~~~~~~~
/usr/include/GLES3/gl32.h:507:60: error: 'void __glewActiveTexture(GLenum)' redeclared as different kind of entity
  507 | GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture);
      |                                                            ^
/usr/include/GL/glew.h:22286:40: note: previous declaration 'void (* __glewActiveTexture)(GLenum)'
22286 | GLEW_FUN_EXPORT PFNGLACTIVETEXTUREPROC __glewActiveTexture;
      |                                        ^~~~~~~~~~~~~~~~~~~
nigels-com commented 11 months ago

Generally speaking it's not expected that both GLEW and OpenGL headers can both be included for a given compilation unit.

My first impression is that glew.h ought to be guarding with __gles2_gl32_h_ in the same manner as it is for __gl_h_.