[Lazarus] Determine OS at runtime
Marco van de Voort
marcov at stack.nl
Tue Jan 27 22:10:34 CET 2009
On Tue, Jan 27, 2009 at 01:01:04PM -0500, Lee Jenkins wrote:
> Dumb question:
>
> What is the best way to determine the OS platform at runtime?
That depends what you expect. OS and architecture are mostly compiletime.
FPC/Lazarus mostly busies itself with a very course "os-architecture"
combination, but doesn't care much about versions and variants (e.g. win9x
and winNT are both "win32")
IOW {$ifdef linux} will return "linux" for a Linux binary, even when it is
running on FreeBSD. The opposite would probably also be true if Linux had a
FreeBSD emulation mode.
This information can be retrieved in String form using the {$I } directive,
as documented in the FPC documentation:
http://www.freepascal.org/docs-html/prog/progsu38.html#x45-430001.1.38
If you want more detailed information, probably you need to go OS specific.
However the unices have a call for this, fpuname:
http://www.freepascal.org/docs-html/rtl/baseunix/fpuname.html
which makes it at least semi-generic.
More information about the Lazarus
mailing list