Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3977692
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:57:13+00:00 2026-05-20T04:57:13+00:00

I am trying to pass a callback function from C++ to OpenGL (C API):

  • 0

I am trying to pass a callback function from C++ to OpenGL (C API):

gluQuadricCallback(qobj, GLU_ERROR, errorCallback);

where errorCallback is a function in a file compiled as C++ code and is declared as

void errorCallback();

The code compiles cleanly with g++ 4.4 on Linux but gives the following error with mingw32 g++ 4.4 on Windows:

..\glwidget.cpp:172: error: invalid conversion from 'void (*)()' to 'void (*)()'

..\glwidget.cpp:172: error:   initializing argument 3 of 'void gluQuadricCallback(GLUquadric*, GLenum, void (*)())'

Is it some sort of C and C++ mix problem? How can I solve this?

UPDATE: void GLAPIENTRY errorCallback(); doesn’t compile either 🙁
..\glwidget.cpp:129: error: expected initializer before ‘errorCallback’
Now it’s almost sure it is a calling convention issue and has nothing to do with C linkage, see the comments below Thomas’ answer.

UPDATE 2: It seems to me I just run into a messy OpenGL issue concerning GLAPIENTRY, APIENTRY and _GLUfuncptr. Here is a VERY LONG discussion on portability issues:
http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/2007-October/003023.html

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T04:57:14+00:00Added an answer on May 20, 2026 at 4:57 am

    If that’s all you’re getting for an error, that’s a pretty shitty message. This is an issue with calling conventions.

    From my glu.h:

    GLAPI void GLAPIENTRY gluQuadricCallback (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc);
    

    _GLUfuncptr is defined as:

    typedef void (GLAPIENTRYP _GLUfuncptr)();
    

    with

    #ifndef GLAPIENTRYP
    #define GLAPIENTRYP GLAPIENTRY *
    #endif
    
    #ifndef GLAPIENTRY
    #if defined(_MSC_VER) || defined(__MINGW32__)
    #define GLAPIENTRY __stdcall
    #else
    #define GLAPIENTRY
    #endif
    #endif
    

    That explains the difference between Linux and mingw.

    From this, you’d think you need to declare your callback as

    void GLAPIENTRY errorCallback();
    

    and a __stdcall will be slapped onto it when appropriate.

    However, as Ali notes in the comments below, slapping GLAPIENTRY onto the callback signature doesn’t always work. It seems that the GLU 1.3 spec simply specifies that a void (*func)() is accepted. Since some implementations require a _GLUfuncptr instead, which includes the GLAPIENTRY requirement, but others don’t define GLAPIENTRY at all, there is a portability problem here.

    A possible workaround might be:

    #ifndef GLAPIENTRY
    #define GLAPIENTRY
    #endif
    

    and declare all callbacks with the GLAPIENTRY macro nevertheless.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement the 1.6 Mobile Facebook API ( http://code.google.com/p/facebook-actionscript-api/downloads/detail?name=GraphAPI_Mobile_1_6.swc ) into an
I'm trying to make a simple function with js & jquery but I can't
Hi I am working with google maps API I have this huge code, so
I am trying to compute the frequency of a given sound process through the
I have the following problem. I inherited an app and I am trying to
I'm trying to write an object relationship that follows an observer pattern where the
I'm writing a serial port software for Windows. To improve performance I'm trying to
I'm writing a relatively simple proxy app for a web service. The general idea
I have read few F# tutorials and I have noticed how easy is to
I'm just starting to learn D programming language, and happily playing with delegate and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.