I'm testing to see that the NULL constant does indeed occupy the size of a pointer:
ASSERT(sizeof NULL == sizeof(char*));
However, I accidentally wrote the following instead:
ASSERT(sizeof NULL == sizeof char);
That should have compiled, but instead it gave me the following error:
error: expected expression before ‘char’
The same happened after I enclosed NULL
in brackets
ASSERT(sizeof(NULL) == sizeof char);
Isn't the NULL constant usually suppose to be defined by a macro which associates it to a pointer which is equal to 0? The statement was obviously false but as far as I see there was no syntactic error. If that is true, why was I receiving a compilation error?