Xref: utzoo comp.lang.c:11964 comp.sys.ibm.pc:18251 Path: utzoo!utgpu!water!watmath!clyde!att!rutgers!ucsd!nosc!helios.ee.lbl.gov!pasteur!ames!elroy!gryphon!vector!rpp386!jfh From: jfh@rpp386.UUCP (The Beach Bum) Newsgroups: comp.lang.c,comp.sys.ibm.pc Subject: Re: Function declarations (was: MSC v5.1 Bug???) Message-ID: <5680@rpp386.UUCP> Date: 21 Aug 88 17:12:24 GMT References: <10102@genrad.UUCP> <11879@iuvax.cs.indiana.edu> Reply-To: jfh@rpp386.UUCP (The Beach Bum) Organization: HASA, "S" Division Lines: 41 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.) My question is... Why >declare z() inside the functions x() and y()? It doesn't make sense >that the name "z" should be localized to these code blocks, since it >has to be global to the entire file (at least) anyway. Nor do I see >the value of making it a static name, since it references an object >that can't go away or be "reclaimed" outside of x() or y(), namely a >function. Craig's "fix", declaring static z() prior to and outside of >both x() and y() (an almost-protoype kind of declaration), seems like >the only natural thing to do. the msc compiler is broken. the code should compile without error as written (more or less ...) as for the Rational behind why this is being done, ask the programmer. the minimalist coding would be static z(); x() { z(); } y() { z(); } static z() { ; } a possible rationality behind his coding in the fashion he did is that the functions were actually much larger than what we have above and he wanted to indicate that the functions x() and y() were both dependent on z(). as for why z() is declared to be static, any number of reasons exist. -- John F. Haugh II +--------- Cute Chocolate Quote --------- HASA, "S" Division | "USENET should not be confused with UUCP: killer!rpp386!jfh | something that matters, like CHOCOLATE" DOMAIN: jfh@rpp386.uucp | -- apologizes to Dennis O'Connor