Gilles
Gilles

Reputation: 129

Incompatible function prototypes between glew.h and glext.h

I'm trying to compile some code using glew.h and glext.h. Here's a minimal example:

#include <GL/glew.h>
//#include <GL/gl.h> // commenting it doesn't change anything
#include <GL/glext.h>

int main(){
    return 0;
}

I have 6 compile-time errors because of different function prototypes. The first one is:

In file included from main.cpp:3:0:
/usr/include/GL/glext.h:12306:105: error: conflicting declaration ‘typedef void (* PFNGLFRAGMENTLIGHTFVSGIXPROC)(GLenum, GLenum, const GLfloat*)’
 typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params);
                                                                                                         ^
In file included from main.cpp:1:0:
/usr/include/GL/glew.h:16092:28: note: previous declaration as ‘typedef void (* PFNGLFRAGMENTLIGHTFVSGIXPROC)(GLenum, GLenum, GLfloat*)’
 typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params);
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

glew.h:16092:

typedef void (GLAPIENTRY * PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat* params);

glext.h:12306:

typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params);

The difference is the constness of * params.

I'm on Ubuntu 18.04.5 LTS with mesa 20.0.8, glew 2.0.0-5 and gcc 7.5.0 (should I upgrade to Ubuntu 20?).

Upvotes: 3

Views: 580

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473437

I'm trying to compile some code using glew.h and glext.h.

Don't do that. These are two different tools that both do the same thing. They are not intended to be compatible with each other, and neither is expected to work in the presence of the other (in the same source file).

You are either using GLEW or you're manually loading function pointers through glext.h. Pick one.

Upvotes: 6

Related Questions