How to create a macro that call a specified function in C

1 Answer

0 votes
#include <stdio.h>

#define CALL_FUNCTION(func) (func())

void f1(void) {
    printf("f1()\n");
}

void f2(void) {
    printf("f2()\n");
}

int main()
{
    CALL_FUNCTION(f1);
    CALL_FUNCTION(f2);

    return 0;
}




/*
run:

f1()
f2()

*/

 



answered Apr 11, 2022 by avibootz

Related questions

1 answer 150 views
2 answers 217 views
1 answer 153 views
1 answer 160 views
2 answers 206 views
206 views asked Jul 29, 2017 by avibootz
1 answer 165 views
165 views asked Apr 5, 2024 by avibootz
...