Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2005-07

Which OS?

6 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to Thomas Zastrow
Thomas Zastrow wrote
Hello, how can I test - at runtime - under which OS (Linux, Windows and so on) a FPC-program is running?
Try
Var
   ThisOS : String;
begin
   ThisOS := {$I %FPCTARGET%};

results in a string of the form i386-linux or i386-win32.

Michael.

Reply by email

Andres K. Foerster
to Michael Van Canneyt
Michael Van Canneyt wrote 14 lines
>Hello, > >how can I test - at runtime - under which OS (Linux, Windows and so on) a >FPC-program is running? Try Var ThisOS : String; begin ThisOS := {$I %FPCTARGET%}; results in a string of the form i386-linux or i386-win32.

But it is also just the platform the program is compiled for. It doesn't work when you run with an ABI for a different system, ie. you run a FreeBSD binary on NetBSD.

AKFoerster

Reply by email

Michael Van Canneyt
to Andres K. Foerster
Andres K. Foerster wrote 20 lines
Am Monday, dem 11. Jul 2005 schrieb Michael Van Canneyt: >> Hello, >> >> how can I test - at runtime - under which OS (Linux, Windows and so on) a >> FPC-program is running? > > Try > > Var > ThisOS : String; > > begin > ThisOS := {$I %FPCTARGET%}; > > results in a string of the form i386-linux or i386-win32. But it is also just the platform the program is compiled for. It doesn't work when you run with an ABI for a different system, ie. you run a FreeBSD binary on NetBSD.

That shouldn't matter to the program. If I run a Windows binary on Linux under wine, the binary will assume it is running on Windows. Similarly, a linux binary running on BSD will assume it runs on Linux. It's up to the emulator to be 'perfect'.

In other words, an emulator should not be detected, and the program can be assumed to be running on the OS it was compiled for...

Michael.

Reply by email

Jeff Pohlmeyer
how can I test - at runtime - under which OS (Linux, Windows and so on) a FPC-program is running?
  {$IFDEF unix}
     http://www.freepascal.org/docs-html/rtl/baseunix/fpuname.html
  {$ELSE}
    {IFDEF WIN32}
      http://msdn.microsoft.com/library/en-us/sysinfo/base/getversionex.asp
    {$ENDIF}
  {$ENDIF}

Reply by email

Tomas Hajny
to Jeff Pohlmeyer

On Tue, July 12, 2005 13:07, Jeff Pohlmeyer said:

Show quoted text 8 lines
> how can I test - at runtime - under which OS (Linux, Windows and so on) > a FPC-program is running? {$IFDEF unix} http://www.freepascal.org/docs-html/rtl/baseunix/fpuname.html {$ELSE} {IFDEF WIN32} http://msdn.microsoft.com/library/en-us/sysinfo/base/getversionex.asp
      {$ELSE WIN32}
        {$IFDEF OS2}
http://www.warpspeed.com.au/cgi-bin/inf2html.cmd?..\html\book\Toolkt40\CP1.INF+1372
 (or use Dos.DosVersion providing the same information)
           {$ELSE OS2}
             {$IFDEF GO32V2}
 int 21h/3000h & int 21h/3306h (not very reliable, but better than
nothing; the first one is provided in Dos.DosVersion)
             {$ELSE GO32V2}
               {$IFDEF NETWARE}
 Use Dos.DosVersion
               {$ENDIF NETWARE}
             {$ENDIF GO32V2}
        {$ENDIF OS2}
{$ENDIF} {$ENDIF}

OK - I'm not sure if this is what the original author asked for, but this is my extension for some more platforms.

Tomas

Reply by email