[fpc-pascal]Conditional compilation ELSE-IF?
Peter Vreman
peter at freepascal.org
Thu Apr 8 15:43:32 CEST 2004
> I have the following code in a function:
>
> {$IFDEF LINUX}
> Slash := '/';
> {$ENDIF}
> {$IFDEF WIN32}
> Slash := '\';
> {$ENDIF}
>
> Obviously, FPC supports many other platforms. Is there a better way
> to handle this? Also, will this work if I ever cross-compile? Is
> there a way to detect this at run-time rather than compile time?
{$if defined(linux)}
Slash:='/'
{$elseif defined(win32)}
Slash:='\'
{$elseif defined(macos)}
Slash:=':'
{$else}
{$error Unsupported target}
{$endif}
Better is to use PathSeparator from the System unit
More information about the fpc-pascal
mailing list