Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Feb 2002 03:22:55 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Mark Murray <mark@grondar.za>
Cc:        Juha Juntunen <estabur@hotmail.com>, <arch@FreeBSD.ORG>
Subject:   Re: __P macro question 
Message-ID:  <20020202031144.N3615-100000@gamplex.bde.org>
In-Reply-To: <200202011438.g11EbxE98677@greenpeace.grondar.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 1 Feb 2002, Mark Murray wrote:

> > ...
> > People removing __P should also be familiar with the gcc conterpoint:
> >
> >     void foo(char);		/* Wrong; should be "void foo(int);". */
> >     void foo(c) char c; {}
> >
> > gives undefined behaviour in Standard C, but gcc defines its behaviour
> > to be do-what-naive-programmer-expects.  This is only safe provided the
> > wrong prototype for foo() is always in scope before foo() is called;
> > otherwise foo() is sometimes passed an int and sometimes a char, but
> > foo() expects to be passed either an int or a char depending on whether
> > the wrong prototype is in scope for the function body.
>
> So, does this not effectively make a rule, "You will _always_ properly
> prototype functions, and make sure that these proper prototypes are in
> scope before you use (and define) the functions."?

Not quite.  You can use lint to find arg mismatches.  Even the 90%-finished
lint in FreeBSD is effective compared with unavailable link-time checkers.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020202031144.N3615-100000>