Strange syntax error

Discussion in 'C++' started by Qu0ll, Apr 25, 2009.

  1. Qu0ll

    Qu0ll Guest

    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)
    _________________________________________________

    [Replace the "SixFour" with numbers to email me]
     
    Qu0ll, Apr 25, 2009
    #1
    1. Advertising

  2. Qu0ll

    James Kanze Guest

    On Apr 25, 10:59 am, "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 (*)()"?


    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:
    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
     
    James Kanze, Apr 26, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harvey Twyman
    Replies:
    8
    Views:
    568
    August Derleth
    Oct 25, 2003
  2. _wolf

    strange syntax error

    _wolf, Jun 4, 2010, in forum: Python
    Replies:
    1
    Views:
    436
    Jerry Hill
    Jun 4, 2010
  3. Robert Klemme

    Strange IRB Syntax Error

    Robert Klemme, Jun 27, 2003, in forum: Ruby
    Replies:
    2
    Views:
    197
    Robert Klemme
    Jun 27, 2003
  4. Good Night Moon
    Replies:
    9
    Views:
    283
    Rick DeNatale
    Jul 25, 2007
  5. Mark Richards
    Replies:
    3
    Views:
    315
    Tad McClellan
    Nov 18, 2007
Loading...

Share This Page