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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -