Bug when using ifdefs?

Copied from emb.public.prism.language

I have the following block in code that has to compile in both Prism
and Delphi:

{$IFDEF OXYGENE}
uses
{$IFDEF SYMBOL1} unita.unit1, {$ENDIF}
System.Collections.Generic,
System.IO,
System.Text;
{$ELSE}
uses
{$IF COMPILERVERSION < 23.0}
graphics,
{$ELSE}
UITypes,
{$IFEND}
{$IFDEF SYMBOL1} unita, {$ENDIF}
Windows, SysUtils, Classes, DateUtils,
unitx,
unity,
unitz;
{$ENDIF}

The second $ELSE is giving me an error in the oxygene compiler when in
theory the whole block should be being ignored as it is not relevant
to prism. Is this a bug? if not, how can I have defined blocks
that are purely to be parsed by delphi and ignored by prism?

Regards
Keith

Hello Keith,

Thank you for the report. The bug is reproduced and logged for further review (#53963). I’ll let you know when we have any news on that issue.

Best regards.

It’s a limitation. We don’t have a “$IF” compiler/$IFEND, so the compiler sees your $ELSE as belonging to the IFDEF.

a fix for this is:
{$IF COMPILERVERSION < 23.0}
graphics,
{$IFEND}{$IF COMPILERVERSION >= 23.0}
UITypes,
{$IFEND}

Thanks Carlo, that sorted it.

Regards
Keith

{$IFEND}

Carlo,
it’s a new compiler directive, or a typo?
Patrick

@Patrick: New in delphi since v6 or v7 or so. Not supported by Oxygene.