Mail Archives: djgpp/1994/09/21/06:46:57
> So the 'delay' variable is uninitialized, and the output is therefore random.
> Indeed, changing the declaration in your sample program to
>
> static int delay;
>
> produces '0' as output, with DJGPP 1.12.maint2.
As others have already replied, `delay' should be zero even if not
declared static, because it is declared outside any function. The
`static' thing only makes it private to the source file it is
declared in, and therefore avoids the ``bug'' caused by its linkage
to the library-defined name. In addition to what've been said about
this by others, there is a lesson here: any global variable which is
not used across source files, should be *always* declared static, to
minimize a possibility of a name clash with other global symbols.
Being defensive never hurts much, but generally helps a lot.
Eli Zaretskii
- Raw text -