From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ac02560f0af03a21 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-31 08:30:18 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!newsfeed1.easynews.com!easynews.com!easynews!cyclone1.gnilink.net!spamkiller2.gnilink.net!nwrdny02.gnilink.net.POSTED!0f19ed38!not-for-mail From: "Frank J. Lhota" Newsgroups: comp.lang.ada References: <3FEC43B2.5080606@noplace.com> <1072450300.440355@master.nyc.kbcfp.com> <3FEC4E89.2070804@noplace.com> <1072458199.346049@master.nyc.kbcfp.com> <3fec7c21$0$4764$61fed72c@news.rcn.com> <4iBIb.8173$qS3.498@nwrdny03.gnilink.net> <1072883131.278899@master.nyc.kbcfp.com> Subject: Re: GNAT parameter passing, C-style? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: Date: Wed, 31 Dec 2003 16:30:17 GMT NNTP-Posting-Host: 151.203.242.46 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny02.gnilink.net 1072888217 151.203.242.46 (Wed, 31 Dec 2003 11:30:17 EST) NNTP-Posting-Date: Wed, 31 Dec 2003 11:30:17 EST Xref: archiver1.google.com comp.lang.ada:3994 Date: 2003-12-31T16:30:17+00:00 List-Id: "Hyman Rosen" wrote in message news:1072883131.278899@master.nyc.kbcfp.com... > Frank J. Lhota wrote: > The upshot is that even when calling a function without a prototype, the > compiler may pass arguments any way it likes, and it is absolutely not > required to "push" them onto a "stack" in any particular order. It may not be required by the standard, but it is required to support legacy code. Certainly any C code written after ANSI C became widely available should use prototypes, but for many years there was plenty of maintained K&R C code written like this: extern int futz(); { ... if ( futz( name, count ) ) ... } where there is no indication as to whether or not the function takes a variable argument list. You can argue all you want that a compiler is not required to generate correct code for such a program, but the sheer weight of legacy code forces the compiler manufactures to not break code like this. I go back to my original question: does anyone know of a C compiler which, when compiling C (not C++) does not default to the C calling convention (i.e. arguments pushed on the stack in reverse order, and popped off by calling function) in the absence of any indication of another convention? The two C compilers I am currently using (GCC version 3.3.1, MSVC Version 6) both default to the C convention. I recall that every Borland compiler up to 4.0 defaulted to the C convention as well, as did the early Zortech / Symantec compilers. Again, I am not saying this out of fondness for the C calling convention. The original K&R specification, unfortunately, forced the undesirable use of this convention for many years. The C++ people should be congraduated for making a bold enough break from the past to eliminate almost all need for this convention. I should also note that this has never been an issue in Ada. (This is an Ada newsgroup, after all).