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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:02:33+00:00 2026-06-05T00:02:33+00:00

Before that I used such huge things: int* ShowPopUpMessage = (int*)0x004837F0; //declare ((int (__cdecl*)(const

  • 0

Before that I used such huge things:

int* ShowPopUpMessage = (int*)0x004837F0; //declare
((int (__cdecl*)(const char *, char))ShowPopUpMessage)("You see this message!", 0); //call

ehm, I think is no need to tell it’s kinda confusing.

Now I want to declare normal function pointer like that:

int *ShowPopupMessage(const char *, char);

To be able call that function like that:

ShowPopupMessage("asd", 0);

But I can’t assign function address to that pointer. I tried:

int *ShowPopupMessage(const char *, char) = (int*)0x004837F0; //error: function "ShowPopupMessage" may not be initialized

//then this
int *ShowPopupMessage(const char *, char);
ShowPopupMessage = 0x004837F0; //nope

ShowPopupMessage = (int*)0x004837F0; //nope

*ShowPopupMessage = 0x004837F0; //nope

*ShowPopupMessage = (int*)0x004837F0; //nope

uhh. Any other ways?

  • 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-05T00:02:34+00:00Added an answer on June 5, 2026 at 12:02 am

    You really should read the compiler’s diagnostics even with subsequent attempts of solving a compile error. I really doubt that it ever said “nope.”

    A typedef is especially useful when you want to declare a function (or a function pointer) returning a function pointer. In a simple function pointer type expression it doesn’t buy you much, as you really only need to remember the parenthesis when you write one, like this:

    int *ShowPopupMessage(const char*, char); // a function declaration
    int (*ShowPopupMessage)(const char*, char); // a function pointer definition
    

    Both are an easy read for C++ programmers.

    In your case, a typedef might be preferable (as you need to use the type twice), but as you
    seem to have trouble understanding acceptable implicit conversions, I’m not going to hide the problem behind a typedef curtain.

    In the examples above, you’re mostly only changing the left-hand side of things. C++ does not allow implicit conversions of integer types to (any) pointer types, and in a similar fashion, it doesn’t allow implicit conversions of object pointer types to function pointer types. If you want to interpret an integer as a function pointer, you need a cast — and not just any cast, but a reinterpret_cast to a function pointer type.

    // this is OK (with the cast), but ShowPopupMessage is not a function pointer,
    // but a pointer to int
    int *ShowPopupMessage = (int*)0xDEADBEEF;
    
    // this is incorrect, as C++ does not allow implicit conversions from
    // object pointers to function pointers
    int (*ShowPopupMessage)(const char*, char) = (int*)0xDEADBEEF;
    
    // this is OK (assuming you know what you're doing with 0xDEADBEEF)
    int (*ShowPopupMessage)(const char*, char) =
            (int(*)(const char*, char))0xDEADBEEF;
    
    // this is preferable in C++ (but it's not valid C)
    int (*ShowPopupMessage)(const char*, char) =
            reinterpret_cast<int(*)(const char*, char)>(0xDEADBEEF);
    
    // (this is a possibility in C++11)
    #include <functional>
    std::function<int(const char*, char)> ShowPopupMessage =
            reinterpret_cast<int(*)(const char*, char)>(0xDEADBEEF);
    // it's used in much the same way as function pointers are
    // i.e. you call it like you always call them: ShowPopupMessage("", ' ')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wow, I've never really used symlinks that much before, but this is really boggling:
I was trying to update a framework that we used before, since they had
I have used ImageView's before and understand the different scale types that can be
Just trying to understand that - I have never used it before. How is
I am trying to check that an address isn't being used before I delete
I haven't used $_SERVER['HTTP_REFERER'] before and i dont knw how i can use that
I am editing a certain website which before used the port 80 (default) that
I never thought before, only I used the method getPassword that returning an array
I have a lengthy JavaScript file that passes JSLint except for used before it
There's a lot of buzz about MooseX::Method::Signatures and even before that, modules such as

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.