Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Strange syntax error

0 views
Skip to first unread message

Qu0ll

unread,
Apr 25, 2009, 4:59:28 AM4/25/09
to
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)
_________________________________________________
Qu0llS...@gmail.com
[Replace the "SixFour" with numbers to email me]

red floyd

unread,
Apr 25, 2009, 10:49:45 AM4/25/09
to
Qu0ll wrote:
> 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_ );
> }
>
>
http://www.parashift.com/c++-faq-lite/pointers-to-members.html#faq-33.2

James Kanze

unread,
Apr 26, 2009, 6:06:15 AM4/26/09
to
On Apr 25, 10:59 am, "Qu0ll" <Qu0llSixF...@gmail.com> wrote:
> 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.

--
James Kanze (GABI Software) email:james...@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

0 new messages