Re: Question on #if

From: Chris Gilbert (chris@buzzbee.freeserve.co.uk)
Date: 11/27/99


Del wrote:
>
> I was taking a look at how autowiz gets initiated and noticed this, my
> question is - Is this ok to not have the #endif?
>
> My common sense says that the endif should be there.. but then again, with C
> I notice common sense does not always apply!
>
> #if defined(CIRCLE_UNIX) || defined(CIRCLE_MACINTOSH)

[snip]

> #ifdef CIRCLE_UNIX
>
> /* clean up our zombie kids to avoid defunct processes */
> RETSIGTYPE reap(int sig)

Scrolling down to line 1979 (or so) :

#endif  /* CIRCLE_UNIX */

and further down (line 2053):
#endif  /* CIRCLE_UNIX || CIRCLE_MACINTOSH */

With #if's you can nest them like you can normal if's.  The effect here
is that some signals are on both macs and unix, and some only unix.  The
standard way to show which endif closes which #if is to add a comment.
Similair to what you might do with a closing } in long bits of nested
code.

Without out an #endif I'd expect you're compiler to complain in some
way.

Chris


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST