Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!bbn!clsib21!bhj From: bhj@clsib21.UUCP Newsgroups: comp.lang.c Subject: Re: Pet peeve #1473 Message-ID: <533@clsib21.UUCP> Date: Tue, 1-Sep-87 13:05:37 EDT Article-I.D.: clsib21.533 Posted: Tue Sep 1 13:05:37 1987 Date-Received: Wed, 2-Sep-87 07:25:38 EDT References: <9001@brl-adm.ARPA> <526@clsib21.UUCP> <1021@argus.UUCP> Organization: CLSI Inc., Newtonville, MA Lines: 34 Summary: properly written code In article <1021@argus.UUCP>, ken@argus.UUCP (Kenneth Ng) writes: > In article <526@clsib21.UUCP>, bhj@clsib21.UUCP (Burt Janz) writes: > > In article <9001@brl-adm.ARPA>, ultra!wayne@ames.arpa (Wayne Hathaway) writes: > > > >>>> #define STRERR() ((errno >=0 && errno < sys_nerr) ? \ > > > What's wrong with this? Simply that it doesn't tell you what the > > > unknown value of errno *IS*! When I first saw code like this in > > > Wayne Hathaway ultra!wayne@Ames.ARPA > > Hmmmm... ever heard of running cpp by itself, grokking the output, > > and seeing where the macros are expanded? > > Burt Janz > > But if the software was properly written I wouldn't have to do this. > Kenneth Ng: Post office: NJIT - CCCC, Newark New Jersey 07102 Ah, but if the code had been properly written, this discussion wouldn't be taking place. Remember, the original complaint was about errno not being set by a macro... Frankly, it gets me peeved when I pick up someone else's code and have to wade through it, trying to figure out what macros are used where, and having to UNhide all of those wonderful macros which are HIDing stuff. Many is the time I've used the output of cpp as the source to the modified code. And, I've also modified the output to cpp and created macros again, thus perpetuating the problem. The major problem with macros occurs when too much manipulation is done within them. I try to keep my macro usage to a minimum, preferring to either create functions or to directly use code. I know, macros are supposed to help you with that. But macros are often NOT named effectively, and this contributes to the confusion. All I can suggest with the macro not returning errno is: rewrite it. Burt Janz