nested @#ifndef and @#ifdef don't work

Email from @JohannesPfeifer:

If I use

@#define risk_sharing = 0
@#if risk_sharing == 0
  @#ifndef endogenous_discount_factor
       @#define endogenous_discount_factor = 1
  @#endif
@#endif

In a mod-file, I get an error

@#if/@#ifdef/@#ifndef not matched by an @#endif or file does not end with a new line (unexpected end of file)