#if, #ifdef Nesting

You can nest #ifdef's within #if's, and vice-versa, throughout the config files.   Per-machine #if directives take precedence over logical #ifdef directives.  So, for example,

#if linux
      [ aaa ... ]
#ifdef paranoid
      [ bbb ... ]
#endifdef
      [ ccc ... ]
#endif
would have the aaa, bbb & ccc content appear only on linux machines, and the bbb content only if paranoid is set (defined).  On the other hand, with
#ifdef paranoid
     [ aaa ... ]
#if linux
     [ bbb ... ]
#endif
     [ ccc ... ]
#endifdef
the aaa and ccc content would appear on all machines, if paranoid is set, while the bbb content would appear only on linux machines with paranoid defined.

This, however, would lead to error on non-linux systems:

#ifdef paranoid
     [ aaa ... ]
#if linux
     [ bbb ... ]
#endifdef
     [ ccc ... ]
#endif
because there would be no concluding #endifdef on those machines.  In other words, be careful about intertwining #if-#endif's with #ifdef-#endifdef's.

Observe that you can set/unset defines on a per-machine basis in the defines.cfg file, for example

#if dbserver
paranoid     TRUE
#else
paranoid     FALSE
#endif
Or, alternatively and equivalently,
paranoid
#if dbserver
             TRUE
#else
             FALSE
#endif


prev page 1st page next page
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software | DevNotes | Licensing | Authors | Pikt-Users | Pikt-Workers | Links | SiteIndex | ContactUs
Page best viewed at 1024x768.   Page last updated 2006-09-10.   This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.   Copyright © 1998-2006 Robert Osterlund.  All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title