Francois Cartegnie said:
Just 2 cents:
"with the value defined in headers".
I guess that any well written code (not referring to 0) should work
with null redefined to MAX_INT (as long it's not in it's allocatable
address range)
As James pointed out, you meant NULL, not null, and you probably meant
((void*)INT_MAX).
I believe that redefining a macro defined in a standard header invokes
undefined behavior, but we'll ignore that for now.
What you're saying, I think, is that if a well-written program used
some unique non-null pointer value as a null pointer, then it would
still work as long as it *consistently* uses this unique value. Let's
say it defines, in some header:
#define MY_NULL ((void*)INT_MAX)
and used MY_NULL everywhere in place of NULL.
This could be made to work, but you'd have to watch out for references
to null pointers that don't use the NULL macro:
void *ptr = 0; /* sets ptr to NULL, not MY_NULL */
if (ptr) { ... } /* compares ptr to NULL, not MY_NULL */
But the biggest problem is that the standard library uses actual null
pointers in many places. You'd have to compare the result of fopen()
to NULL, but compare the result of your own foo() to MY_NULL.
The choice of which pointer representation to set aside as a null
pointer value is largely an arbitrary one, and you can change it as
long as you do so consistently. (I think that was the point you were
trying to make.) But changing it consistently requires changing the
compiler, the standard runtime library, any additional libraries
provided by the OS or by third parties, *and* your own program.