Question based on discussion of the answer about sizeof NULL .
Here are the standard pieces:
If you want to see a
void *NULL which expands to a null pointer constant
It seems that instead of #define NULL ((void*)0) , it is not forbidden to simply #define NULL 0 , as is done in pluses. Then it turns out that sizeof NULL is equal to either sizeof (void*) or sizeof (int) (in the variant sizeof 0 ).
However, @Vlad from Moscow claims that NULL in C must be a pointer.
NULL in C is defined as a pointer.
The words "cast to type void *" are of key importance in the above quotation.
Here,
илиis related not to the casting, but to the form of the expression. And this is exactly how NULL is defined.
So is it permissible for C (without pluses) to have?
#define NULL 0 And if it is acceptable, then why is it used in compilers?
#ifndef NULL #ifdef __cplusplus #define NULL 0 #else #define NULL ((void *)0) #endif #endif instead of a simpler version with zero for both languages?
After all, in C, even the overloading of functions was not possible, so that something could be broken.
execlarguments must end with a null (constant (!)) Pointer (it doesn’t matter(void *)0or at least(float *)0). By the way, he understands, even if unistd.h is not included. Therefore, to use everywhere just 0 will not work. - avp__nonnull((1, 2))refers to the first and second call list arguments, not the last (its compiler callssentineland thewarning: missing sentinel in function call [-Wformat=])warning: missing sentinel in function call [-Wformat=]. Moreover, it is somewhere written forexecl(and obviously, heaps of other functions), because when I remove unistd.h and manually prescribe the same execl and execf declarations, I only swear on execl - avp(void *)0 != 0. I think it's easy to understand why. - 0andriy