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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:02:35+00:00 2026-05-27T05:02:35+00:00

If I have a prototype that is declared as: void foo(int (*fi)(void *, void

  • 0

If I have a prototype that is declared as:

void foo(int (*fi)(void *, void *))

And I call the function with something like this:

foo(int (*)(void*, void*)(bool_expr ? func1 : func2));

Where func1 and func2 are defined as follows:

int func1(char *s1, char *s2);
int func2(int *i1, int *i2);

Is the function call casting one of the functions (func1 ^ func2) to the type of the function required by foo? Could I also make the prototype for foo look like:

void foo(int (*)(void *, void *))
  • 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-27T05:02:36+00:00Added an answer on May 27, 2026 at 5:02 am

    As commented the code as posted did not compile.

    FWIW, this compiles and executes as you would expect with VC2010:

    int func1(char *s1, char *s2) { printf("func1\n"); return 0; }
    int func2(int *i1, int *i2)   { printf("func2\n"); return 0; }
    
    void foo(int (*)(void *, void *));
    
    int main(int argc, char** argv)
    {
        foo(2 == argc ? (int(*)(void*,void*))func1 :
                        (int(*)(void*,void*))func2);
    
        return 0;
    }
    
    void foo(int (*a)(void *, void *))
    {
        a((void*)0, (void*)0);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function whose prototype is as follows: void foo(const char * data);
I have this function declared: Object.prototype.append = Array.prototype.append = append = function( tag ){
In my program i declared a function prototype like : void callToPrint(LPTSTR , LPVOID
I have a plugin declared like this. (function ($) { var settings = {
I have a prototype representing a particual IFrame. That prototype have a function called
I have a custom control that has the following prototype. Type.registerNamespace('Demo'); Demo.CustomTextBox = function(element)
I have this code in jQuery, that I want to reimplement with the prototype
Let's say I have a very simple PrototypeJS class that looks like this: var
I have the function prototype here: extern C void __stdcall__declspec(dllexport) ReturnPulse(double*,double*,double*,double*,double*); I need to
I have this code: void PrintMainParameters(int n, char* array[]) { int i = 0;

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.