From owner-freebsd-arch Fri Feb 1 6:29:38 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 0C84337B405 for ; Fri, 1 Feb 2002 06:29:34 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id BAA16171; Sat, 2 Feb 2002 01:29:15 +1100 Date: Sat, 2 Feb 2002 01:31:23 +1100 (EST) From: Bruce Evans X-X-Sender: To: Juha Juntunen Cc: Subject: Re: __P macro question In-Reply-To: Message-ID: <20020202012011.U3304-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, 1 Feb 2002, Juha Juntunen wrote: > >>>static int sendfile __P((struct printer *pp, int type, char *file, > >>> int format)); > >>> > >>>for a procedure declaration of: > >>> static int > >>> sendfile(pp, type, file, format) > >>> struct printer *pp; > >>> int type; > >>> char *file; > >>> char format; > >>> { > >> > >>That's *EXCATLY* why I'm converting the old, but still legal in c89, > >>style to new style. You get warnings that you didn't get before. > > > >The compiler is broken, if it accepts the second when the > >first prototype is in scope. > > > >It's a broken compiler, period. > > How is the compiler broken, question mark. > > Are you perhaps objecting to the type of the last parameter > ("int format" vs "char format")? Please see Ansi Classic, chapter > "3.5.4.3 Function declarators (including prototypes)", in particular > page 69 lines 19-22. In C99, 6.7.5.3 paragraph #11 seems to apply > similarly. Right. I don't trust anyone who is not familiar with this point to globally remove __P. 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. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message