Question

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

Was it helpful?

Solution

GLUquadricObj needs to be deleted using:

gluDeleteQuadric(GLUquadricObj *);

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top