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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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: 2004-01-05 13:06:15 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!elnk-pas-nf1!newsfeed.earthlink.net!cyclone.socal.rr.com!cyclone2.kc.rr.com!news2.kc.rr.com!twister.socal.rr.com.POSTED!53ab2750!not-for-mail Sender: kst@nuthaus.mib.org Newsgroups: comp.lang.ada Subject: Re: GNAT parameter passing, C-style? 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> From: Keith Thompson User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 05 Jan 2004 21:06:00 GMT NNTP-Posting-Host: 66.91.248.166 X-Complaints-To: abuse@rr.com X-Trace: twister.socal.rr.com 1073336760 66.91.248.166 (Mon, 05 Jan 2004 13:06:00 PST) NNTP-Posting-Date: Mon, 05 Jan 2004 13:06:00 PST Organization: RoadRunner - West Xref: archiver1.google.com comp.lang.ada:4125 Date: 2004-01-05T21:06:00+00:00 List-Id: "Frank J. Lhota" writes: [...] > In vanilla (i.e. original K&R) C, there are no argument lists in function > declarations. For that matter, vanilla C does NOT even require functions > declarations. If an undeclared function is called in vanilla C, the > unconverted argument list is assumed to be OK, the calling convention is > assumed to be C, and it is assumed that the function returns an int. The term "vanilla" implies that the original K&R C is the default version of the language. It isn't. The 1990 ISO C standard is almost universally implemented these days (though not always perfectly); it's difficult to find a C compiler that doesn't implement prototypes, for example. (My ancient SunOS 4.1.3 box has a K&R C compiler, but I rarely use it, since I've also installed gcc.) > ANSI C depreciates this loose approach to functions. ANSI C strongly > encourages the full declaration of all functions used, including argument > lists. For compatability, however, ANSI C accepts function declarations with > no argument lists (e.g. "double sin();"), as well as the calling of > undeclared functions. Since there is no requirement that the user will > declare a function's argument list (or the function for that matter), a C > compiler may not be able to tell whether a function accepts a variable > argument list or not. For that reason, C compilers have to assume the C > calling convention, unless the user indicates via declaration or command > line options. Nitpick: it's "deprecates". The latest ISO C standard, C99, requires full declarations for functions, but it's not widely implemented yet; so far, it's not catching on as quickly as C90 did. (C90, the 1990 ISO C standard, is essentially identical to C89, the 1989 ANSI C standard.) If a function takes a variable number of arguments, any call to that function without a prototype in scope invokes undefined behavior. That means the implementation isn't required to diagnose the problem, but the standard places no constraints on the program's behavior. (Over in comp.lang.c, we traditionally say that it's allowed to make demons fly out your nose.) One of the biggest advantages of Ada over C is that it has far fewer instances of undefined behavior. An advantage of C over Ada is that it uses the straightforward term "undefined behavior" rather than "erroneous execution". > Every C compiler that I have worked with uses the C calling convention by > default when compiling C (as opposed to C++) code. [...] There is no such thing as "the C calling convention", though some implementations may (misleadingly) use the phrase to refer to the default calling convention used by a particular C compiler on a particular system. -- Keith Thompson (The_Other_Keith) kst-u@mib.org San Diego Supercomputer Center <*> Schroedinger does Shakespeare: "To be *and* not to be"