Nesting ifdefs

Is it OK to nest macro ifdefs inside other ifdefs?

such as:

#ifdef A
  #ifndef B
    #define C
  #endif
  #ifndef D
    #define E
#endif

Is it OK to nest macro ifdefs inside other ifdefs?

Does it work when you try it ?

Not sure, that's why I am asking. I am trying to change the prescaler on the ADC

I now realize I'm being lazy by asking, will go away and try

The thing is, by trying, you're not endangering anything, and if you use #error a couple of times, it's very easy to prove/disprove your scheme.

MartynC:
Is it OK to nest macro ifdefs inside other ifdefs?

such as:

#ifdef A

#ifndef B
    #define C
  #endif
  #ifndef D
    #define E
#endif

Perfectly legal, and OK too.( But you missed something,but compiler will tell you Ha Ha)
It behaves same as if( ) , the only annoying “thing” Arduino IDE does not tell you where “blocks” of "ifdef / #endif are, so when you preproccess blocks exceeds page or few pages AND you miss the #endif it is a challenge to find. On the other hand code block enclosed in {} are “clickable” to tell you where ( or close) you missed the closing brackets.
IMHO #ifdef / #endif is great to control your memory usage , so can go wild with Serial without loosing sleep over running out of memory while debugging your code.

Moderator edit: Fixed tags. Again. {sigh}

thanks for the replies and confirm it does work. Noticed the missing endif.

I have a project that can use different types of keypad, digital or analogue, and I am using a define and ifdefs to select which code to compile.