Hi everyone,

I recently installed g++ 2.95.2 on a linux system, and I am now
getting some compilation failures when compiling code which references
glu.h as per the latest CVS images.

More specifically, consider the following C++ code:

#include <GL/glu.h>

void foo(GLUquadricObj *qobj)
{
  gluQuadricDrawStyle(qobj, GLU_FILL);
}


With g++ 2.91.66 (which is the one which comes with RedHat 6.1, I think),
you get:

$ g++ -c foo.C
foo.C: In function `void foo(struct GLUquadricObj *)':
foo.C:5: warning: conversion from `enum {anonymous}' to `enum GLenum'
$ g++ --version
egcs-2.91.66


But with 2.95.2, you now get an error:

$ g++ -c foo.C
foo.C: In function `void foo(GLUquadricObj *)':
foo.C:5: conversion from `enum {anonymous}' to `enum GLenum'
$ g++ --version
2.95.2


The problem is that gluQuadricDrawStyle and frieds is defined as:

GLUAPI void GLAPIENTRY gluQuadricDrawStyle( GLUquadricObj *quadObject,
                                          GLenum drawStyle );

whereas GLU_FILL is defined as an anonymous enum:

enum {
...
        GLU_FILL        = 100012,
...
};

and g++ is refusing to cast an anonymous enum it a GLenum. I'm not
enough of a C++ language lawyer to tell if g++ is wrong or not,
but I suspect that since a lot of people using Mesa will also
want to run the "latest and greatest" g++, this could be a problem.

Note that moving the same pre-processed source to IRIX gets the
same error on the MIPSpro C++ compiler:

$ CC -c foo.C
"foo.C", line 20: error(1164): argument of type "enum <unnamed>" is
          incompatible with parameter of type "GLenum"
    gluQuadricDrawStyle(qobj, GLU_FILL);
                              ^

1 error detected in the compilation of "foo.C".


Note that in IRIX, gl.h defines:

typedef unsigned int GLenum;

and glu.h defines:

#define GLU_FILL                             100012

which is why you don't normally get these kinds of problem on that
platform.

I imagine that there is a good reason for using enums instead of
#defines in the the Mesa gl.h and glu.h?

JF


Jean-Francois Panisset                                [EMAIL PROTECTED]
Software Engineer
Discreet Logic 


_______________________________________________
Mesa-dev maillist  -  [EMAIL PROTECTED]
http://lists.mesa3d.org/mailman/listinfo/mesa-dev

Reply via email to