C preprocessor: macro function to call printf() -
i want conditionally use either printf() or statement:
#define use_printf #ifdef use_printf #define macrofn(str) printf(str) #else #define macrofn(str) some_statement #ifndef use_printf
but i'm getting following error:
incompatible implicit declaration of built-in function 'printf'
what doing wrong? thanks
you don't have include <stdio.h>
before macro definition. need #endif
#if
have started. example, following programme work fine:
#define use #ifdef use #define asd printf("asd") #else #define asd puts("kek") #endif #include<stdio.h> int main( ) { asd; getchar( ); return 0; }
so... yeah.
Comments
Post a Comment