nested directives?

geoff07

Senior Member
a quick question for those familiar with pre-processor directives:

Does nesting work? for example, which directive is ended first in this example:

#ifdef A
#ifdef B
.. code
#endif '1
.. code
#endif '2

Does #endif 1 close #ifdef B (as I hope) or #ifdef A (as might explain something). I couldn't find any reference and it could have been coded either way.

thanks!
 

Aries

New Member
Code:
#ifdef I2C
#ifdef SlaveI2C
hi2csetup i2cslave,I2Caddress
#endif
#ifdef MasterI2C
hi2csetup i2cmaster,I2Caddress,i2cslow,i2cbyte
#endif
#endif
This is from one of my programs.
The first #endif goes with the SlaveI2C, the second goes with MasterI2C, the third goes with I2C.
You can check (with PE6) by setting Options>Diagnostics>Display Pre-processor Output
and then defining whichever combinations you like and using Check Syntax to display the resulting code (it won't compile, of course, without I2Caddress being defined somehow)
 
Top