[Mono-list] Determining the platform at compile and run time

Fergus Henderson fjh@cs.mu.OZ.AU
Fri, 31 Oct 2003 12:29:11 +1100

On 29-Oct-2003, Chris Seaton <chris@chrisseaton.com> wrote:
> How do I know what OS my program is running on at run time?

Why do you care?

In general, it is a bad idea to test for particular operating systems.
Such code inevitably requires tweaking when ported to a new system,
and sometimes it is quite hard to know what the right answer is anyway.
For example, if you have some old code that tests whether the system
is MacOS or Unix, what do you do when this system is ported to MacOS X,
which has a Unix kernel?  If you test for Unix versus Windows, what
should happen when the program runs under Cygwin?

Instead, it is better to test for the particular functionality that you
require, e.g. directory path separator, support for X Windows, etc.

Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.