警告:“struct GLUquadric”的前向声明;
我得到以下内容
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
GLUquadricObj
需要使用以下方法删除:GLUquadricObj
needs to be deleted using:对于未使用
new
分配的对象,不得使用delete
。在不了解 OpenGL 的情况下,我确信您必须在这里使用 gluDeleteQuadric 。You mustn't use
delete
for objects not allocated withnew
. Without knowing anything about OpenGL, I'm quite sure you have to usegluDeleteQuadric
here.