Subject: Re: A little program I wrote that core dumps. Should it?
To: Peter Naulls <pnaulls@wave.co.nz>
From: Philip Blundell <pjb27@pobox.com>
List: port-arm32
Date: 06/16/1997 19:36:30
On Tue, 17 Jun 1997, Peter Naulls wrote:
> > > void main(void) {
> > > FILE *f;
> > > f = fopen("/dev/lpt0");
> > > while (!feof(f)) putchar(fgetc(f));
> > > }
> >
> > A quick look in the (HPUX) manpage shows the following:
> >
> > FILE *fopen(const char *pathname, const char *type);
> >
> > so use `fopen("/dev/lpt0", "r")' !
>
> Yeah, you're right of course - had slipped my mind. This could
> just as easily cause a crash. I suggest people use -Wall on gcc :)
A missing argument is an error, not just a warning. You should always
include the appropriate headers (eg <stdio.h>) - that way you get
prototypes and the compiler can catch things like this.
(Or did you mean that -Wall causes gcc to moan about function calls that
haven't been prototyped?)
p.