Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does C expression ((void(*)(void))0)(); mean?

Tags:

People also ask

What does (( void 0 do in C?

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; ).

What does void *) 0 represent?

(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* .

Is void *) 0 the same as null?

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.