Mail Archives: djgpp/1996/11/13/11:11:33
On Wed, 13 Nov 1996, Ole Winther wrote:
> I really dont know how I can assign value's to the NULL pointer, can someone
> describe how this can be done?
The most frequent case is when you declare a pointer which is a global
variable (and is therefore initialized to zero even if you didn't give it
any value), then use it before assigning any value to it. Example:
char *ptr; /* will be initialized to zero by the linker */
void myfunc(void)
{
char c = *ptr; /* this will crash your program under DJGPP */
}
The simplest way to catch these errors is to run your program until it
crashes, then run symify. It will add filenames and source line numbers
to the stack dump. You should then run your program under a debugger,
put a breakpoint at the line which crashed (this is the uppermost of the
lines printed by `symify') and when that breakpoint is hit, examine the
pointers which that line is using to look for the pointer(s) which have
zero or garbled values.
- Raw text -