Functor errors

This is a discussion on Functor errors within the C++ Programming forums, part of the General Programming Boards category; Would appreciate a pointer here (pun intended). It's been a long time since I've touched anything low-level. Apologies if this ...

  1. #1
    Dae
    Dae is offline
    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 04: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,311
    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%.

  3. #3
    Dae
    Dae is offline
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21