It should be noted that, when used as a macro (say, #define noop ((void)0) ), the (void) prevents it from being accidentally used as a value (like in int x = noop; ).
(void*)0 is a null pointer constant, whose value is a null pointer of type void* , so by the semantics of parenthesized expressions ((void*)0) also has a value that is a null pointer of type void* .
You can use an integer constant expression with the value 0 or an expression that is cast to (void *)0 as a null pointer constant. The macro NULL and value 0 are equivalent as null pointer constants, but NULL is cleaner because it represents the purpose of using the constant for a pointer.
((void(*)(void))0)();
So we have integer 0 type casting to this tricky type (void(*))(void)
and then executing it. Source claims that this should work, but what does it actually?
This must be one of those C jokes like #define TRUE FALSE
, I suppose.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With