我得到以下
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实际上是一个foward声明,但是
我想避免这个警告。
我想要为这个唯一的功能禁止这个警告。
或者通过包含正确的标题来解决警告。我在/ usr / include / GL中使用了grep,但没有找到完整的类型。
我正在使用Arch Linux
mesa 7.8.2-3
和
gcc 4.5.1-1
答案 0 :(得分:4)
GLUquadricObj
需要使用以下命令删除:
gluDeleteQuadric(GLUquadricObj *);
答案 1 :(得分:1)
对于未使用delete
分配的对象,您不得使用new
。在不了解OpenGL的情况下,我很确定你必须在这里使用gluDeleteQuadric
。