From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f890526de6a8a218 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!newsfeed.stueberl.de!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: How to detect OS type and version? Date: Thu, 13 Oct 2005 20:44:04 +0100 Organization: Pushface Message-ID: References: NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1129232642 23005 62.49.19.209 (13 Oct 2005 19:44:02 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Thu, 13 Oct 2005 19:44:02 +0000 (UTC) Cancel-Lock: sha1:eP9TPFz7wZCrrXCxSpRCrO/39Pw= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) Xref: g2news1.google.com comp.lang.ada:5607 Date: 2005-10-13T20:44:04+01:00 List-Id: Martin Dowie writes: > Roger Blum wrote: >> Is there a way within Ada (GNAT 3.15p) to tell whether the >> application is running on Linux or Windows (and the version of the >> OS)? > > There is no single standard why... yet! > > I think that you will be able to do this with "package > Ada.Environment_Variables" come Ada200Y, e.g. We would like to distinguish the PowerPC VxWorks target from the Intel Windows development environment! At the moment we just test the endianness, not great but it works for us. One solution, similar to what we use in another context, is as suggested by Stefan. We used a visible constant enumeration, eg type environment_kind is (host, target); environment : constant environment_kind := host; and compiler path selection (via GNAT project file). That way, GNAT (certainly at -O2) will generate no object code for the 'wrong' branch. OK, you get to recompile the world, but that was going to happen anyway!