Path: utzoo!mnetor!uunet!husc6!rutgers!lll-lcc!ames!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: dpANS C and `static' functions Message-ID: <9971@mimsy.UUCP> Date: 29 Dec 87 05:41:49 GMT References: <4668@pyr.gatech.EDU> <495@xyzzy.UUCP> <136@ateng.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 39 In article <136@ateng.UUCP> chip@ateng.UUCP (Chip Salzenberg) writes: >[Some existing compilers already require the first declaration of a static function to include the keyword `static', i.e., f() { g(); } static g() { is illegal.] >I like it. For example, on the '286 in "large model", static functions >could be made "near", thus improving performance and reducing stack usage. Static functions could indeed be made near . . . but if and only if the compiler first looks at entire source files, in which case the whole reason for making `static wins' illegal goes away. Consider the following: % cat file1.c static int f() { return (3); } /* a silly function */ p() { ... = f(); /* this can use a near call */ } int (*sneaky())() { return (f); } % cat file2.c extern int (*sneaky())(); main() { int (*fn)(); fn = sneaky(); ... = (*fn)(); /* but this cannot */ } % The problem is the same as that of inlining functions at compile (rather than link) time. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris