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 237 views
2 answers 331 views
1 answer 235 views
1 answer 251 views
2 answers 319 views
319 views asked Jul 29, 2017 by avibootz
1 answer 270 views
270 views asked Apr 5, 2024 by avibootz
...