Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!think.com!snorkelwacker.mit.edu!bloom-picayune.mit.edu!news From: scs@adam.mit.edu (Steve Summit) Newsgroups: comp.lang.c Subject: Re: structured entry of #if preprocessor commands Message-ID: <1991Feb10.204604.28908@athena.mit.edu> Date: 10 Feb 91 20:46:04 GMT References: <1991Feb10.063915.5476@ccu.umanitoba.ca> Sender: news@athena.mit.edu (News system) Reply-To: scs@adam.mit.edu Distribution: na Organization: Thermal Technologies, Inc. Lines: 43 In article <1991Feb10.063915.5476@ccu.umanitoba.ca>, Jason Smigiel writes: >Is it common practice not to structure preprocessor commands in ANSI C? >I looked in the K&R2 reference manual, under A12,(very first paragraph) and >it states: > > "Lines beginning with #, perhaps preceded by white space, communicate > with this preprocessor." > > So it seems completely valid to me, I just wanted to know if this was a >smart thing to do or am I entirely insane? You're not insane. However, leading whitespace before preprocessor directives is a relatively new "innovation." Older compilers do not allow it, and there are enough of them around that people tend not to use leading whitespace at all. Furthermore, those of us who have been using the older compilers for years are so used to it that nicely indented nested #if's look, well, pretty weird. You're correct, though, in thinking that more nicely structured #if's would be better. What I can't explain is why the following style, which most old compilers would accept, has never been widespread (and which therefore looks equally weird to me): #if defined(MSDOS) # if defined(ANSI) # include "ms_ansi.h" # endif #else /* not msdos */ # if !defined(ATARIST_MWC) && !defined(MAC) && !defined(AMIGA) # ifndef VMS # include # endif # include # endif #endif For all the ranting that I and others do about the importance of good style and clear program layout, there are always these little hypocrisies. Steve Summit scs@adam.mit.edu