的提前聲明我得到以下警告:「結構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的
檯面7.8.2-3
和
GCC 4.5.1-1
Thx,這就是解決方案。 – LabOctoCat 2010-11-09 02:22:09