Thread: Functor errors

  1. #1
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034

    Smile Functor errors

    Would appreciate a pointer here (pun intended).

    It's been a long time since I've touched anything low-level. Apologies if this is simple. I didn't post this in GD because it's basic C, not game related. I'm receiving errors with an app that uses SDL. I've found the error seems to vary based on platform. I'm not sure, it looks like a simple declaration issue, causing error on assignment.

    error: cannot convert ‘void (*)(GLuint)’ to ‘void ()(GLuint)’ in assignment
    Code:

    middle of SDL_opengl.h
    Code:
    GLAPI void APIENTRY glUseProgram (GLuint);
    top of renderer_ogl.cpp
    Code:
    typedef void (APIENTRY* PFNGLUSEPROGRAMPROC) (GLuint program);
    PFNGLUSEPROGRAMPROC glUseProgram = 0;
    middle of renderer_ogl.cpp
    Code:
    glUseProgram = (PFNGLUSEPROGRAMPROC) SDL_GL_GetProcAddress("glUseProgram");
    I changed the last one to dereference:
    Code:
    glUseProgram = *(PFNGLUSEPROGRAMPROC) SDL_GL_GetProcAddress("glUseProgram");
    It said

    error: cannot convert ‘void ()(GLuint)’ to ‘void ()(GLuint)’ in assignment
    I actually recall function pointers were suppose to be pointers... the error doesn't really make sense, and I'm just confusing myself. Until tomorrow.

    Thanks
    Last edited by Dae; 02-24-2011 at 05:29 AM.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The asterix you added is being applied to the return value from the function, not to the function pointer.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  3. #3
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    You're right. I don't think that original code is incorrect now. I think I need to use a compiler flag. It's a little disorienting, using command-line compiler + some Python called waf-script. It's probably just some compiler/SDL issue.

    Sorry for the topic, thanks anyway.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

Popular pages Recent additions subscribe to a feed