Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: comp.lang.c Subject: Re: Motivation behind a particular piec Message-ID: <9021@utzoo.UUCP> Date: Wed, 2-Dec-87 14:04:23 EST Article-I.D.: utzoo.9021 Posted: Wed Dec 2 14:04:23 1987 Date-Received: Wed, 2-Dec-87 14:04:23 EST References: <981@gumby.UUCP>, <236100007@prism> Organization: U of Toronto Zoology Lines: 18 > That way, the run version of the program has the variables > declared static, while the debug version has them global, which > on many debuggers makes their values easier to obtain. Another reason for doing this sort of thing -- the reason why STATIC is found in my code -- is an incompatibility between some current compilers and X3J11. How do you declare the return value of a static function in advance? X3J11 (unless it's changed lately, I haven't had a chance to read the latest draft yet) says that if you want the thing to be static, the word "static" had better appear in the first mention of it. So the forward declaration would be "static char *foo();" or words to that effect. My current compiler croaks on that, however. So to cope with my current environment while getting the code right for the future, I instead write "STATIC char *foo();", put "#define STATIC static" inside "#ifndef STATIC" up near the front, and use "-DSTATIC=" to convince my compiler to like it. -- Those who do not understand Unix are | Henry Spencer @ U of Toronto Zoology condemned to reinvent it, poorly. | {allegra,ihnp4,decvax,utai}!utzoo!henry