警告:“struct GLUquadric”的前向声明;

发布于 2024-09-30 21:43:26 字数 950 浏览 5 评论 0原文

我得到以下内容

x.cpp: In member function ‘X’:
x.cpp:153:10: warning: possible problem detected in invocation of delete operator:
x.cpp:146:19: warning: ‘quadric’ has incomplete type /usr/include/GL/glu.h:271:7: warning: forward declaration of ‘struct GLUquadric’
x.cpp:153:10: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.

通过这段代码

146: GLUquadricObj * quadric;
147: quadric = gluNewQuadric();
148: gluQuadricNormals(quadric, GLU_SMOOTH);
149: gluQuadricTexture(quadric, GL_TRUE);
150:
151: gluSphere(quadric, object.radius(), slices, stacks);
152:
153: delete quadric; 

,我明白为什么它会这样做,GLUquadricObj 实际上是一个前向声明,但

我想避免这个警告。

我想要么抑制这个单一功能的警告。

或者通过包含正确的标题来解决警告。我在/usr/include/GL中使用了grep,但没有找到完整的类型。

我正在使用 Arch Linux

mesa 7.8.2-3

gcc 4.5.1-1

I get the following

x.cpp: In member function ‘X’:
x.cpp:153:10: warning: possible problem detected in invocation of delete operator:
x.cpp:146:19: warning: ‘quadric’ has incomplete type /usr/include/GL/glu.h:271:7: warning: forward declaration of ‘struct GLUquadric’
x.cpp:153:10: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.

With this code

146: GLUquadricObj * quadric;
147: quadric = gluNewQuadric();
148: gluQuadricNormals(quadric, GLU_SMOOTH);
149: gluQuadricTexture(quadric, GL_TRUE);
150:
151: gluSphere(quadric, object.radius(), slices, stacks);
152:
153: delete quadric; 

I understand why it does that, GLUquadricObj is in fact a foward declaration, BUT

I want to avoid this warning.

I would like either to suppress this warning for that sole function.

Or resolve the warning by including the right header. I used grep in /usr/include/GL and didn't find the complete type.

I'm using Arch Linux

mesa 7.8.2-3

and

gcc 4.5.1-1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

白芷 2024-10-07 21:43:26

GLUquadricObj 需要使用以下方法删除:

gluDeleteQuadric(GLUquadricObj *);

GLUquadricObj needs to be deleted using:

gluDeleteQuadric(GLUquadricObj *);
他是夢罘是命 2024-10-07 21:43:26

对于未使用 new 分配的对象,不得使用 delete。在不了解 OpenGL 的情况下,我确信您必须在这里使用 gluDeleteQuadric 。

You mustn't use delete for objects not allocated with new. Without knowing anything about OpenGL, I'm quite sure you have to use gluDeleteQuadric here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文