> 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





_______________________________________________
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to