Path: utzoo!utgpu!watserv1!watmath!att!rutgers!psuvax1!wuarchive!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.std.c Subject: Re: prototypes required ? Keywords: printf stdargs prototypes Message-ID: <483@taumet.com> Date: 19 Oct 90 18:36:51 GMT References: <4026@otis.oakhill.UUCP> <14164@smoke.BRL.MIL> <2150@lupine.NCD.COM> Organization: Taumetric Corporation, San Diego Lines: 49 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 . Are all of the function listed in 4.9.4 thru 4.9.10 !required to have declarations within ? If so, are they required !to have prototyped declarations? Non-prototyped? Either? Section 4.1.2.1 says that a header must declare or define all identifiers in its associated section. I find it hard to read the standard to say that non-prototype declarations are OK, but that may be prejudice. I haven't found an explicit statement that full prototypes are required. ! ... the creators of the file in question had cheated !and put a declaration like the following in it: ! int vfprintf (FILE *, const char *, void *); !Obviously, that last formal parameter type is not correct! Yes, they cheated, and this is not standard-conforming. The prototype must match the one in the standard. !I tried changing the last formal type to (a more correct) `va_list', but !when I did that this changed the file into something that could !*not* be included ALL BY ITSELF into *any* given file. Rather, it now always !had to be preceeded by a #include . !So what it the `correct' thing to have in the file regarding the !vfprintf function (and friends)? cannot just #include , since no header may include any of the others. The implementor cannot require you to #include prior to . The implementor must supply a prototype for functions which are equivalent to using the typedefs in the non-included header file. The implementor supplies all the headers, so this is possible, apart from being required. So in we might have: struct _T { .... }; typedef struct _T va_list[2]; Then in we would have: struct _T; int vfprintf(FILE *, const char*, struct _T*); This meets all of the ANSI requirements. -- Steve Clamage, TauMetric Corp, steve@taumet.com