Sign in Join

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

Mailing lists / lazarus / 2009-01

Determine OS at runtime

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Lee Jenkins

Dumb question:

What is the best way to determine the OS platform at runtime?

I would like to be able to position things like dialog form buttons dependent on the OS.

Thanks,

Warm Regards, Lee

Reply by email

Lee Jenkins
to Mattias Gaertner
Mattias Gaertner wrote 11 lines
On Tue, 27 Jan 2009 13:01:04 -0500 Lee Jenkins wrote: > Dumb question: > > What is the best way to determine the OS platform at runtime? You can already at compile time. http://wiki.lazarus.freepascal.org/Code_Conversion_Guide#Useful_compiler_variables_.2F_defines_.2F_macros

Thanks Mattias. I was aware of the defines but thought maybe there was a built-in function in LCL that returned an enumerated type or constant or something similar.

No problem, I will just create a singleton that relies on the defines to return an enumerated type of my own.

> I would like to be able to position things like dialog form buttons > dependent on the OS. For common buttons you can use TButtonPanel.

Thanks I will this rearrange itself depending on the OS? Is that what you are saying? I have not experience with this component.

Thanks again,

Warm Regards, Lee

Reply by email

Lee Jenkins
to Mattias Gaertner: On Tue, 27 Jan 2009 13:01:04 -0500 You can already at compile time.…
Mattias Gaertner wrote 11 lines
On Tue, 27 Jan 2009 13:01:04 -0500 Lee Jenkins wrote: > Dumb question: > > What is the best way to determine the OS platform at runtime? You can already at compile time. http://wiki.lazarus.freepascal.org/Code_Conversion_Guide#Useful_compiler_variables_.2F_defines_.2F_macros

Thanks Mattias. I was aware of the defines but thought maybe there was a built-in function in LCL that returned an enumerated type or constant or something similar.

No problem, I will just create a singleton that relies on the defines to return an enumerated type of my own.

Is there a complete list of the defines available. That link seems to show just a few in examples.

> I would like to be able to position things like dialog form buttons > dependent on the OS. For common buttons you can use TButtonPanel.

Thanks I will this rearrange itself depending on the OS? Is that what you are saying? I have not experience with this component.

Thanks again,

Warm Regards, Lee

Reply by email

Marco van de Voort
to Lee Jenkins: Dumb question: What is the best way to determine the OS platform at runtime? I would like…
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.

Reply by email