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 8117257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:06:21+00:00 2026-06-06T04:06:21+00:00

I’m trying to create a map of function names and function pointers using __stdcall.

  • 0

I’m trying to create a map of function names and function pointers using __stdcall. Here is how I currently get my function pointers:

typedef int (CALLBACK* InitializeDLL)(int,int);
InitializeDLL initializeDLL = (InitializeDLL)GetProcAddress(hInstanceLibrary, "InitializeDLL");

and now my Map:

map<string, int *__stdcall> mapInt;
mapInt["InitializeDLL"] = initializeDLL; //throws error for "InitializeDLL cannot be assigned to entity of type int*"

That error is exactly what I expected, but I need to add a type apparently in front of __stdcall. If I remove the “int” in the front then it complains with:

Error: expected a type specifier

If I try to compile it after only creating the map object with the “int” included in the front, it throws the error:

error C2059: syntax error : '>'

Which does not make much sense to me. So what is the correct way to use __stdcall as a type for a map? Adding the int in front of it seemed suspicious to me, but if I don’t add it then it complains that it needs a type specified.

Also, CALLBACK is a #define for __stdcall if that is confusing.

  • 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-06-06T04:06:23+00:00Added an answer on June 6, 2026 at 4:06 am

    A function pointer type is not limited to a single function. For instance, your InitializeDLL function pointer type can hold a pointer to any function that has this signature: int foo(int,int).

    Perhaps CallbackFunction would be a better name for that typedef, since it encompasses all functions having a signature that can used for a callback:

    typedef int (CALLBACK* CallbackFunction)(int,int);
    CallbackFunction initializeDLL =
        (InitializeDLL)GetProcAddress(hInstanceLibrary, "InitializeDLL");
    map<string, CallbackFunction> mapInt;
    mapInt["InitializeDLL"] = initializeDLL;
    

    There are more generic ways to handle functions (and even member functions). If you’re capable/willing to use new C++11 features, you can use std::function and std::bind. If not, then you can use boost::function and boost::bind. The Boost and C++11 versions of those facilities are used in exactly the same way. The Boost documentation will be a lot more helpful than cppreference.

    If you show us how you intend to invoke the callback functions in your map (including cases where the function signatures are different), I might be able to show you examples on how to use function and bind for your use case.


    You might consider having all your command callbacks have the same function signature, then have each callback be responsible for extracting whatever parameters they need to do their work. The object that contains the command parameters can be passed as an argument to the callback function.

    You can also consider passing a list of parameters to your callback functions in the form of std::vector<boost::any> or std::vector<boost::variant>. The callback function then converts each boost::any or boost::variant to the specific type associated with that particular parameter. If the command parameter types are of simple built-in types, you can even use std:vector<UnionOfPossibleParameterTypes>, where UnionOfPossibleParameterTypes is a plain old C-style union.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

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.