Article View: comp.std.c
Article #1858Re: prototypes required ?
From: Mark Hall
Date: Fri, 19 Oct 1990 00:04
Date: Fri, 19 Oct 1990 00:04
37 lines
2452 bytes
2452 bytes
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
Technical Details
Message-ID:
<130952@pyramid.pyramid.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!cunews!bnrgate!uunet!shelby!snorkelwacker!usc!zaphod.mps.ohio-state.edu!mips!prls!pyramid!markhallShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!bnrgate!uunet!shelby!snorkelwacker!usc!zaphod.mps.ohio-state.edu!mips!prls!pyramid!markhall From: markhall@pyrps5.pyramid.com (Mark Hall) Newsgroups: comp.std.c,gnu.gcc.help Subject: Re: prototypes required ? Keywords: printf stdargs prototypes Message-ID: <130952@pyramid.pyramid.com> Date: 19 Oct 90 00:04:16 GMT Sender: daemon@pyramid.pyramid.com Reply-To: markhall@pyrps5.pyramid.com (Mark Hall) Organization: Pyramid Technology Corp., Mountain View, CA Lines: 37