Xref: utzoo comp.lang.c:11995 comp.sys.ibm.pc:18286 Path: utzoo!attcan!uunet!sdrc!scjones From: scjones@sdrc.UUCP (Larry Jones) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: Function declarations (was: MSC v5.1 Bug???) Message-ID: <356@sdrc.UUCP> Date: 22 Aug 88 21:02:05 GMT References: <10102@genrad.UUCP> <11879@iuvax.cs.indiana.edu> <5680@rpp386.UUCP> Organization: Structural Dynamics Research Corp., Cincinnati Lines: 32 In article <5680@rpp386.UUCP>, jfh@rpp386.UUCP (The Beach Bum) writes: > In article <11879@iuvax.cs.indiana.edu> bobmon@iuvax.UUCP (RAMontante) writes: > >Craig Dawson asks about a program in which two routines try to call a > >third, somewhat as follows: > > > >x() { static z(); z(); } > >y() { static z(); z(); } > > > >static z() { ; } > > > >(MSC apparently chokes; BTW, TurboC accepts it.) > > the msc compiler is broken. the code should compile without error > as written (more or less ...) NO!!! Amazingly enough, MSC got this right - the code is wrong. Think about this similar code: x() { static z[]; z[0] = 3; } y() { static z[]; z[0] = 5; } static z[10]; You wouldn't expect that to work, would you? If something is declared within a block, it must be defined within the same block unless it is declared extern. Since you can't define functions within a block, you can't declare a static function within a block. Sorry. ---- Larry Jones UUCP: uunet!sdrc!scjones SDRC scjones@sdrc 2000 Eastman Dr. BIX: ltl Milford, OH 45150 AT&T: (513) 576-2070 Nancy Reagan on superconductivity: "Just say mho."