Article View: comp.std.c
Article #4366Re: macro versus function in standard headers
From: Mark Brader
Date: Fri, 17 Nov 1995 20:58
Date: Fri, 17 Nov 1995 20:58
30 lines
1843 bytes
1843 bytes
> The implementation's <stdlib.h> > has to declare abs but does not have to declare a prototype for it. If you strain to read the standard so that it provides the least possible information, you can interpret it as not requiring one. > > 7.10.6.1/4.10.6.1 shows the prototype for abs() ... > > 7.10.6.1/4.10.6.1 has the line > #include <stdlib.h> > right above the line > int abs(int j); > Does this mean that <stdlib.h> is required to #include itself before > declaring abs with a prototype? No ... the section is labelled "Synopsis." > It describes what programs have to do or what alternative methods used > by programs must be equivalent to. Nothing in the standard gives it that meaning, so we must fall back on a common sense reading of the synopsis. Sections 7.1.2/4.1.2 and 7.1.3/4.1.2.1 state that the header declares the function. In order for the standard to be useful, the reader of the standard must know how the function is declared. The only information provided is the declaration in the synopsis. Ergo, the only sensible reading is that the standard requires the header to provide that declaration (or an equivalent one). Which means that the prototype is required. -- Mark Brader, msb@sq.com | "Common sense isn't any more common on Usenet SoftQuad Inc., Toronto | than it is anywhere else." -- Henry Spencer My text in this article is in the public domain.
Technical Details
Message-ID:
<1995Nov17.205820.24657@sq.com>Path:
arc1-ca.pugleaf.net!spool.mu.edu!torn!sq!msbReferences:
<487rls$rci@newshost.lanl.gov> <48caqa$rl@usenet.pa.dec.com> <1995Nov15.103729.9184@sq.com> <48guvu$h68@usenet.pa.dec.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!spool.mu.edu!torn!sq!msb From: msb@sq.com (Mark Brader) Subject: Re: macro versus function in standard headers Message-ID: <1995Nov17.205820.24657@sq.com> Organization: SoftQuad Inc., Toronto, Canada References: <487rls$rci@newshost.lanl.gov> <48caqa$rl@usenet.pa.dec.com> <1995Nov15.103729.9184@sq.com> <48guvu$h68@usenet.pa.dec.com> Date: Fri, 17 Nov 1995 20:58:20 GMT