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,bc41e6a6a2da78a9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-18 15:43:45 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn4feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail From: "David Thompson" Newsgroups: comp.lang.ada References: <87sn1s6f6a.fsf@almroth.com> <87wuqt7o9r.fsf@deneb.enyo.de> <87znvpo813.fsf@CERT.Uni-Stuttgart.DE> <87k7mso2lk.fsf@deneb.enyo.de> Subject: Re: Variable arguments magic in Ada to C code X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: Date: Sun, 18 Aug 2002 22:43:45 GMT NNTP-Posting-Host: 12.89.142.164 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1029710625 12.89.142.164 (Sun, 18 Aug 2002 22:43:45 GMT) NNTP-Posting-Date: Sun, 18 Aug 2002 22:43:45 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:28201 Date: 2002-08-18T22:43:45+00:00 List-Id: Florian Weimer wrote : > lutz@iks-jena.de (Lutz Donnerhacke) writes: ... > Quite a lot of GNU C code breaks when compiled with a conforming > C compiler because prototypes do not match old-style function > definitions (I'm not sure if prototypes were allowed at all for > old-style function definitions before C99). This is not very clear; I think you mean declarations using prototype syntax (new in C89/90, like C++) in calling code for a function whose definition (implementation, body) uses old-style (K&R1) parameter declaration syntax. If so, you _can_ (since C89) write a prototype correctly matching any definition that was legal in K&R1 -- but you must be careful, because parameters of "less than normal width" types, specifically integer types below (signed or unsigned) int and float (the only floating type below double) were promoted in K&R1 calls and thus the promoted types must be used in the prototype to get the correct matching, even though the definition can be written with the narrower type(s). gcc will warn about mistakes here if the prototype declaration is visible at the definition (e.g. by #include'ing the "spec" .h in the "body", a commonly recommended practice) if you use -pedantic, at least 2.95.2 which is what I have handy to check. If this is meant to relate to the earlier posts about vararg versus non-vararg functions in C, there was and is no K&R1 syntax for vararg -- the _only_ correct way to call or define/implement vararg functions in C is with prototype syntax. (Or of course a compatible implementation of another language, like Ada.) -- - David.Thompson 1 now at worldnet.att.net