Strange syntax error

Q

Qu0ll

I am trying to compile the open source OGLFT library with MinGW on Windows
Vista but encounter this strange error:

OGLFT.cpp: In member function `void OGLFT::Filled::init()':
OGLFT.cpp:2538: error: invalid conversion from `void (*)()' to `void (*)()'
OGLFT.cpp:2538: error: initializing argument 3 of `void
gluTessCallback(GLUtesselator*, GLenum, void (*)())'

How could "void (*)()" not be the same as "void (*)()"?

The actual line of source looks like this:

gluTessCallback( tess_obj_, GLU_TESS_VERTEX,
(GLUTessCallback)vertexCallback );

where vertexCallback is defined as:

void Filled::vertexCallback ( VertexInfo* vertex )
{
if ( vertex->color_tess_ != 0 )
glColor4fv( vertex->color_tess_->color( vertex->v_ ) );

if ( vertex->texture_tess_ != 0 )
glTexCoord2fv( vertex->texture_tess_->texCoord( vertex->v_ ) );

glVertex3dv( vertex->v_ );
}

I am new to C++ so I am not sure how much more of the code I need to show
you. I guess I just can't understand what the error message is actually
trying to say.

--
And loving it,

-Qu0ll (Rare, not extinct)
_________________________________________________
(e-mail address removed)
[Replace the "SixFour" with numbers to email me]
 
J

James Kanze

I am trying to compile the open source OGLFT library with
MinGW on Windows Vista but encounter this strange error:
OGLFT.cpp: In member function `void OGLFT::Filled::init()':
OGLFT.cpp:2538: error: invalid conversion from `void (*)()' to `void (*)()'
OGLFT.cpp:2538: error: initializing argument 3 of `void
gluTessCallback(GLUtesselator*, GLenum, void (*)())'
How could "void (*)()" not be the same as "void (*)()"?

It's a very bad error message. Given the little bit of code you
show, it's clearly omitting both the parameter types and the
fact that the function is a member (supposing that Filled is a
class, and not a namespace).
The actual line of source looks like this:

gluTessCallback( tess_obj_, GLU_TESS_VERTEX,
(GLUTessCallback)vertexCallback );
where vertexCallback is defined as:
void Filled::vertexCallback ( VertexInfo* vertex )
{
if ( vertex->color_tess_ != 0 )
glColor4fv( vertex->color_tess_->color( vertex->v_ ) );
if ( vertex->texture_tess_ != 0 )
glTexCoord2fv( vertex->texture_tess_->texCoord( vertex->v_ ) );
glVertex3dv( vertex->v_ );
}

It would help if we could also see the declaration of
gluTessCallback, to see what it is expecting. And what
GLUTessCallback is. However, if Filled is a class, then the
expression (GLUTessCallback)vertexCallback shouldn't compile,
regardless---the only thing you can do with a member function is
call it (using an instance of the class, so you need a . or a ->
operator to the left, and a () operator to the right), or take
its address, in which case, you must use a qualified id and the
address of operator, e.g.:
&Filled::vertexCallback.
No other uses are legal.
I am new to C++ so I am not sure how much more of the code I
need to show you. I guess I just can't understand what the
error message is actually trying to say.

It is more than vague. But to answer fully your question, we
need to know 1) whether Filled is a class or a namespace, 2) how
GLUTessCallback is defined, and 3) the signature (declaration)
of gluTessCallback.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top