gpt4 book ai didi

c++ - glew.h 和 glext.h 之间不兼容的函数原型(prototype)

转载 作者:行者123 更新时间:2023-12-04 00:52:57 26 4
gpt4 key购买 nike

我正在尝试使用 glew.h 和 glext.h 编译一些代码。这是一个最小的例子:

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

int main(){
return 0;
}

由于不同的函数原型(prototype),我有 6 个编译时错误。第一个是:

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);

区别在于 * params 的常量。

我在 Ubuntu 18.04.5 LTS 上使用 mesa 20.0.8、glew 2.0.0-5 和 gcc 7.5.0(我应该升级到 Ubuntu 20 吗?)。

最佳答案

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

不要那样做。这是两种不同的工具,它们都做同样的事情。它们不旨在彼此兼容,并且预计两者都不能在彼此存在的情况下(在同一源文件中)工作。

您要么正在使用 GLEW,要么正在通过 glext.h 手动加载函数指针。选择一个。

关于c++ - glew.h 和 glext.h 之间不兼容的函数原型(prototype),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65009898/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com