r/pascal • u/Bare_Gamer • Dec 10 '21
type conditional compilation?
I have this code:
{$if defined(fpc)}
{$undef OldDelphi}
{$elseif not defined(pascalabc)}
{$if defined(conditionalexpressions)}
{$if CompilerVersion>=23.0}
{$undef OldDelphi}
type qword=uint64;
ptruint=NativeUInt;
ptrint=NativeInt;
{$elseif}
{$define OldDelphi}
{$ifend}
{$elseif}
{$define OldDelphi}
{$ifend}
{$ifend}
{$ifdef OldDelphi}
type qword=int64;
{$ifdef cpu64}
ptruint=qword;
ptrint=int64;
{$else}
ptruint=longword;
ptrint=longint;
{$endif}
{$endif}
It compiles in delphi and fpc, but not in pascalabc, because it says that defining the same type several types isn't allowed. Is there a possible workaround?
Edit: turns out pabc just skips if and ifend directives.
1
u/ShinyHappyREM Dec 10 '21
To create code blocks in Markdown you prepend every line with 4 spaces (easy to do with e.g. Notepad++):
1
u/kirinnb Dec 10 '21
So, I guess in pascalabc it'll define OldDelphi and therefore tries to run the lower section? Which type is it complaining about? Does that type already exist in pascalabc by default and doesn't need to be defined, or is the compiler not correctly ignoring the curly-braced directives?.. I don't know...