Macro that replaces all calls to printf with nothing

  • A+
Category:Languages

I want to create a macro that replaces all calls to printf, more specifically mbedtls_printf (which behaves the exact sameway as printf) with nothing.

I know I can use #define mbedtls_printf to replace mbedtls_printf with nothing, but this will still leave the parameters/parenthesis intact.

Edit - I forgot to mention that mbedtls_printf is a macro that replaces itself with sgx_printf

 


I would go with:

#define printf(...) (0) 

The benefit here is that it will continue to compile in cases where someone actually bothers to check the return from printf (rare but not unheard of).

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: