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!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: How to detect OS type and version? Date: 13 Oct 2005 17:21:32 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <20051013115001.60b6a695@pscube.informatik.uni-stuttgart.de> <20051013203728.2322138f@pscube.informatik.uni-stuttgart.de> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1129238492 28643 192.74.137.71 (13 Oct 2005 21:21:32 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 13 Oct 2005 21:21:32 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:5616 Date: 2005-10-13T17:21:32-04:00 List-Id: Stefan Bellon writes: > Nothing more than historical reasons. In some files where OS specific > code resides, we have something like the following on package level: > > Is_MSWindows : constant Boolean := Get_OS = "Windows"; > > We hope that GNAT can optimize enough to propagate the Boolean constant > and only include the active configuration in a case like > > if Is_MSWindows then > Do_It_The_MSWindows_Way; > else > Do_It_The_UNIX_Way; > end if; Compilers will probably not be able to optimize this unless Get_OS is inlined. I believe GNAT refuses to inline functions that return String. > But yes, making it an enumeration is a neater solution (done now). ... and add pragma Inline to the function. By the way, a case statement would be better than an if statement, because then you get the benefit of the full coverage rules. "Not windows" might imply "unix" today, but what if you add a third possible value? - Bob