Christopher-Vance@adfa.oz.au (10/18/90)
gwyn@smoke.BRL.MIL (Doug Gwyn) writes: | Yes, you definitely must have a prototype in scope before calling a | variable-argument function in a strictly conforming program. Which means that gcc -ansi on a Pyramid cannot compile such a thing. I am informed that the only way to make printf work is to *omit* the prototype.
karl@haddock.ima.isc.com (Karl Heuer) (10/18/90)
In article <1964@ccadfa.adfa.oz.au> Christopher-Vance@adfa.oz.au writes: >gwyn@smoke.BRL.MIL (Doug Gwyn) writes: >| Yes, you definitely must have a prototype in scope [for printf()] > >Which means that gcc -ansi on a Pyramid cannot compile such a thing. I am >informed that the only way to make printf work is to *omit* the prototype. Presumably this is caused by having to link with the native implementation of printf(), and hence will be fixed when the FSF releases the GNU library. Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint
markhall@pyrps5.pyramid.com (Mark Hall) (10/19/90)
In article <18561@haddock.ima.isc.com> karl@ima.isc.com (Karl Heuer) writes: >In article <1964@ccadfa.adfa.oz.au> Christopher-Vance@adfa.oz.au writes: >>gwyn@smoke.BRL.MIL (Doug Gwyn) writes: >>| Yes, you definitely must have a prototype in scope [for printf()] >> >>Which means that gcc -ansi on a Pyramid cannot compile such a thing. I am >>informed that the only way to make printf work is to *omit* the prototype. There are two issues to cover here. First, Doug said (quoting loosely) "you must have a prototype in scope [for the *program* to be strictly conforming]". He didn't say that an ANSI compiler had to flag the non-conformance. Second, let me point out that on some architectures, the calling sequence changes if you are calling a stdarg function (put args on the stack instead of in registers, say). If you don't have an ellipsis prototype visible at the call site, the compiler will not know to emit the correct calling sequence, and hence the program will die mysteriously or give obscure results at runtime. Does the ANSI compiler which compiled this program have to tell you ahead of time that you forgot the prototype? No. The adjective "conforming" applies to programs, not compilers. So does "gcc -ansi" really reject a program which calls a stdarg function without a prototype? Does it manufacture a link-time check? Otherwise, how can it tell "printf" is a stdarg function? > >Presumably this is caused by having to link with the native implementation of >printf(), and hence will be fixed when the FSF releases the GNU library. > I'm not sure what the problem is with the the Pyramid printf function which is incompatible with gcc when you have an ellipsis prototype for printf. Does gcc put ellipsis arguments on the stack or something? If so, why? -Mark Hall (smart mailer): markhall@pyrps5.pyramid.com (uucp paths): {ames|decwrl|sun|seismo}!pyramid!markhall
darcy@druid.uucp (D'Arcy J.M. Cain) (10/19/90)
In article <1964@ccadfa.adfa.oz.au> Christopher-Vance@adfa.oz.au writes: >gwyn@smoke.BRL.MIL (Doug Gwyn) writes: >| Yes, you definitely must have a prototype in scope before calling a >| variable-argument function in a strictly conforming program. > >Which means that gcc -ansi on a Pyramid cannot compile such a thing. I am >informed that the only way to make printf work is to *omit* the prototype. Is gcc on the Pyramid broken that badly? On my SysV 386 system: $ cat ptest.c extern int printf(const char *format, ...); int main(void) { printf("%d %s\n", 5, "Hello world"); return(0); } $ gcc -Wall -ansi ptest.c -o ptest $ ptest 5 Hello world $ -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | I support gun control. West Hill, Ontario, Canada | Let's start with the government! + 416 281 6094 |