Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!uunet!bu.edu!olivea!tymix!cirrusl!sunstorm!dhesi From: dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) Newsgroups: comp.lang.c Subject: Re: cdecl and pascal keywords Message-ID: <2847@cirrusl.UUCP> Date: 4 Jan 91 05:25:39 GMT References: <12184@sybase.sybase.com> <11742@alice.att.com> <310@audfax.audiofax.com> <26075@uflorida.cis.ufl.EDU> Sender: news@cirrusl.UUCP Organization: Cirrus Logic Inc. Lines: 38 In <26075@uflorida.cis.ufl.EDU> jdb@reef.cis.ufl.edu (Brian K. W. Hook) writes: >...but I was wondering whether there is a NOTICEABLE difference >in speed and size of program that uses PASCAL declarations... This belongs in comp.lang.pascal, does it not? Seriously, please don't assume that comp.lang.c readers will be able to answer questions about nonstandard extensions of the C programming language. The "pascal" keyword is used by MS-DOS-specific compilers, and a better place to ask the question will be one of the MS-DOS newsgroups. However... The effect of using the "pascal" keyword is to tell the compiler that it need not assume that traditional C style function calls, with a posibly variable number of parameters, will be used. The compiler can thus generate code that allows the called function to pop the stack before it returns, rather than inserting stack-popping code after each call to each function. Difference in speed: probably not noticeable. Difference in code size: a few bytes (let's say about 2 bytes) saved each time any function is called. If a function is called 10 times, that means 20 bytes saved by making that function a "pascal" function. In theory, there is no need for a "pascal" keyword if you're using ANSI C, since the compiler knows whether or not a prototype is in scope, and can generate efficient or inefficient code accordingly. In practice, it seems (unverified suspicion) that most MS-DOS compilers don't take advantage of the presence of ANSI C prototypes for such optimization but do take advantage of the "pascal" keyword. This could be because of the fear that the user might link the object code resulting from his C source with an assembly language program, or out of the knowledge that most MS-DOS users don't use "lint" and can therefore not check function calls for consistency across files. -- History never | Rahul Dhesi becomes obsolete. | UUCP: oliveb!cirrusl!dhesi