I want to conditionally use either printf() or a 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 the following error:
incompatible implicit declaration of built-in function 'printf'
What am I doing wrong? Thanks
#include <stdio.h>?#endifinstead of the#ifndef USE_PRINTFwhich means "if USE_PRINTF is not defined", which already is being handled by the#elsepart. You absolutely need an#endiffor each#if.endiffor this error.printfwith just one argument? Shouldn'tputsbe more suitable in most such cases? See also stackoverflow.com/a/16813480/908515