I have seen debug printfs in glibc which internally is defined as (void) 0, if NDEBUG is defined. Likewise the __noop for Visual C++ compiler
Even if so, why type cast it to void? Also, in case of the #define dbgprintf (void) 0, when it's called like dbgprintf("Hello World!"); -> (void) 0("Hello World!"); - what does it mean? – legends2k
Macros replace your code with something else, so if you #defined dbgprint (that accepts x) as
void (0)
then no rewriting of X will occur in replacement, so dbgprintf("Helloworld") will not be converted to (void) 0("Hello world"), but to (void) 0; - not only macro name dbgprint is replaced by (void) 0, but the whole call dbgprintf("...")