#define NULL 0
is an ideal definition in C
eg.
char *ch = NULL ; *ch++ ;
it causes an error, since ch does not indicate anything when executing the increment statement is known by the compiler, assuming the pointer value in the LOOK-UP table is 0
if you are trying to update this pointer, then you are actually changing the contents of CODE that start at 0 of the physical address. For this reason, the first page table entry begins before the code area is not supported.
What exactly is the problem with getting your NULL from where you should ?, i.e.
#include <stddef.h>
or
#include <cstddef>
as pointed out in a comment by @Johannes Rudolph, any trick you do is unlikely to be very promising evidence for things like nullptr, etc.
EDIT: while stdlib (and many others) should include NULL, stddef is the most canonical header [and has been around for decades].
PS All in all, itβs just a bad idea to get involved in such a hoax unless you have a really good reason. You did not expand the thinking that led you to feel the need to do this. If you could add some details about this, this will most likely lead to better answers. Other people who answered the question should have indicated this in their answers, but I think that FGITW, like FGITW, does better: D
EDIT 2: As pointed out by @Yossarian: The only excuse for this is if NULL is defined in the appropriate language agnostic form elsewhere in your system. Examples of this include bare-headed compilers without headers and / or if you write your own standard library from scratch. (In such a blue-bones scenario, I would go with @lilburne's answer (be sure to use 0 as much as possible))
Swapnil
source share