Article View: comp.std.c
Article #1866Re: prototypes required ?
From: Doug Gwyn
Date: Fri, 19 Oct 1990 15:09
Date: Fri, 19 Oct 1990 15:09
33 lines
2339 bytes
2339 bytes
In article <2150@lupine.NCD.COM> rfg@NCD.COM (Ron Guilmette) writes: >Now please excuse my almost total ignorance regarding the x3j11 requirements >regarding the contents of include files, but I don't immediately see where >(in 4.9.1) it says (explicitly) what function are required to be declared >within <stdio.h>. Are all of the function listed in 4.9.4 thru 4.9.10 >required to have declarations within <stdio.h>? If so, are they required >to have prototyped declarations? Non-prototyped? Either? Section 4.1.2.1 says: "Each header declares or defines all identifiers listed in its associated section, ..." While it does not explicitly require that prototypes be used, a strictly conforming program must assume that the standard headers might use prototypes. Otherwise, it would be depending on undefined behavior. Of course it is expected that high-quality implementations WOULD use prototypes in the standard headers, because that would produce better diagnostic capabilities due to being able to check argument types. >... put a declaration like the following in it: > int vfprintf (FILE *, const char *, void *); >I tried changing the last formal type to (a more correct) `va_list', ... <stdio.h> must not rely on the inclusion of <stdarg.h> nor include <stdarg.h> itself. The v*() declarations in <stdio.h> should have the appropriate type directly used in the declaration (i.e. not via a typedef), or else they should use an implementation-reserved identifier for the typedef. For example: /* <stdio.h> example implementation (partial) */ #include <sys/cdefs> /* defines __va_list etc. */ /* [FILE defined here] */ int vfprintf(FILE *, const char *, __va_list); With this technique, the same file (<sys/cdefs>) can be used in the implementation of both <stdio.h> and <stdarg.h>.
Technical Details
Message-ID:
<14195@smoke.BRL.MIL>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!snorkelwacker!mit-eddie!wuarchive!udel!haven!adm!smoke!gwynReferences:
<4026@otis.oakhill.UUCP> <14164@smoke.BRL.MIL> <2150@lupine.NCD.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!snorkelwacker!mit-eddie!wuarchive!udel!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: prototypes required ? Keywords: printf stdargs prototypes Message-ID: <14195@smoke.BRL.MIL> Date: 19 Oct 90 15:09:27 GMT References: <4026@otis.oakhill.UUCP> <14164@smoke.BRL.MIL> <2150@lupine.NCD.COM> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 33