[fpc-pascal]Conditional compilation ELSE-IF?

Michalis Kamburelis michalis at camelot.homedns.org
Thu Apr 8 15:49:03 CEST 2004


Alan Mead wrote:
> 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?  
Use DirectorySeparator constant from System unit or PathDelim from 
SysUtils unit. PathDelim is also Delphi-compatible.

> Also, will this work if I ever cross-compile? 
Those are just constants defined in some units. So they will always 
correspond to the target OS you are compiling to. So everything will 
work when you cross-compile.

 > Is
> there a way to detect this at run-time rather than compile time?
> 
> -Alan
> 
Maybe I don't understand this question, but there's just no need to 
detect value for DirectorySeparator at run-time when this is already 
known at compile-time for all OSes.

Michalis.




More information about the fpc-pascal mailing list