Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: How to find the problem in the object file Date: Thu, 09 Feb 2017 15:20:52 -0800 Organization: None to speak of Lines: 60 Message-ID: References: <23ab01a2-5220-42cb-80b2-20a2b4a35d5c@googlegroups.com> <2beebc58-3f8f-46c6-bd10-e2ec3cf87906@googlegroups.com> <874m03gnc5.fsf@news.bourguet.org> <35f03514-c25d-4372-bbaa-660d78ab7129@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="be0e2eec6e3a3e421f62644bd2dd2876"; logging-data="25086"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gD1bd/H6zR2bxb+qldR3Z" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:+RtRqJnG0oTA5euxQHriiAXdHgw= sha1:gNfQgl3BEqP64N3Bw7DQopKDbhA= Xref: csiph.com comp.lang.c:103578 supercat@casperkitty.com writes: > On Thursday, February 9, 2017 at 1:45:45 PM UTC-6, Jean-Marc Bourguet wrote: >> Keith Thompson writes: >> >> > supercat writes: >> >> On Thursday, February 9, 2017 at 11:01:55 AM UTC-6, Keith Thompson wrote: >> >>> Do you have a compelling example where old-style function >> >>> declarations are actually useful? Perhaps you've already posted >> >>> it here, but if so I can't recall it. I also invite anyone else >> >>> to post examples. >> >> >> >> On some systems, calls to prototyped functions use a different naming and >> >> calling conventions from calls to non-prototyped functions. >> > >> > Name one. >> >> Is this even conforming? I though it was allowed to declare a function >> with a prototype and define it without, without having the prototype >> visible at the point of definition. > > I've observed such behavior with the Keil C51 compiler (which is non- > compliant in a few ways, but strives to comply with the Standard as much > as practical). Then it's hardly relevant. I believe this program is valid: #include void func(); int main(void) { func("Hello, world"); } void func(const char *message) { puts(message); } (The definition could be moved to a different translation unit if that matters.) At the point of the call, the only visible declaration of the function is not a prototype. The function is later defined with a prototype. If different calling conventions were used for prototyped and non-prototyped functions, the call would likely fail somehow. The change I propose making to the standard, removing non-prototype function declarations and definitions, needn't affect any non-conforming implementations if, for example, their non-conforming features are sufficiently useful. (I don't know why Keil would use different calling conventions for prototyped and non-prototype functions, but I'll accept that it does so and that there's some reason for it.) -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"