Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think.com!mintaka!spdcc!ima!dirtydog!karl From: karl@ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: cdecl and pascal keywords Message-ID: <1991Jan04.183243.21124@dirtydog.ima.isc.com> Date: 4 Jan 91 18:32:43 GMT References: <12184@sybase.sybase.com> <11742@alice.att.com> <310@audfax.audiofax.com> <26075@uflorida.cis.ufl.EDU> <2847@cirrusl.UUCP> Sender: news@dirtydog.ima.isc.com (NEWS ADMIN) Organization: Interactive Systems Lines: 34 In article <2847@cirrusl.UUCP> dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) writes: >In theory, there is no need for a "pascal" keyword if you're using ANSI C... Unless the compiler is going to do cross-file analysis (e.g. with a fixup at link time), it would have to assume that all non-variadic functions are pascal-like. (It's irrelevant whether or not a prototype is in scope, since int main(void) { return f(1); } and extern int f(int); int main(void) { return f(1); } are equivalent programs, irregardful of whether f() is defined with or without a prototype in its own source file.) But if the compiler treats non-variadic functions and variadic functions differently, it would break the common (but non-ANSI) usage /* no ! */ int main() { printf("hello, world\n"); return 0; } because it doesn't know that printf() is variadic. Conclusion: an implementation must do one of the following: [0] Be prepared to distinguish variadic from non-variadic functions at link time. [1] Treat all functions as caller-pop (unless otherwise indicated by a nonstandard keyword like "__pascal"). [2] Treat all non-variadic functions as callee-pop, and break old programs such as the above. (A warning "no prototype for printf()" helps here.) [3] Recognize "printf" and friends as reserved words even when is missing. Karl W. Z. Heuer (karl@ima.isc.com or uunet!ima!karl), The Walking Lint