[fpc-pascal]Conditional compilation ELSE-IF?
Marco van de Voort
marcov at stack.nl
Thu Apr 8 16:13:11 CEST 2004
> I have the following code in a function:
>
> {$IFDEF LINUX}
Should be {$ifdef unix}
> Slash := '/';
> {$ENDIF}
> {$IFDEF WIN32}
> Slash := '\';
> {$ENDIF}
>
> Obviously, FPC supports many other platforms. Is there a better way
> to handle this?
See other answers, but for the case it is not alraedy predefined, yet it
works, also for crosscompile. However you should hardly ever use {$if(n)def
linux}, _always_ unix.
The only exeception are really 100% linux only things which are relatively
rare.
> there a way to detect this at run-time rather than compile time?
Yes, but not OS independant. Each OS has its own api for such things :-)
More information about the fpc-pascal
mailing list