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 239 views
2 answers 331 views
1 answer 239 views
1 answer 253 views
2 answers 322 views
322 views asked Jul 29, 2017 by avibootz
1 answer 273 views
273 views asked Apr 5, 2024 by avibootz
...