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,LOTS_OF_MONEY autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: How to find the type of operating system. Date: Thu, 07 Apr 2016 07:45:40 +0100 Organization: A noiseless patient Spider Message-ID: References: <57053167$0$4216$e4fe514c@news.kpn.nl> <533e9e24-e8b6-42e0-b80c-10eae266ee64@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="7565da77bf95a8fe4c6cca3149d50047"; logging-data="16491"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184oYS21KHsRD06EPq9dLYKtn/WdoNfeCU=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:1btqdtxM/bWzjO9Q7E2HLT3vKJo= sha1:J4QPNdoRklqUVKawmHnIKD3uckY= Xref: news.eternal-september.org comp.lang.ada:30030 Date: 2016-04-07T07:45:40+01:00 List-Id: Anh Vo writes: > On Wednesday, April 6, 2016 at 2:41:33 PM UTC-7, Randy Brukardt wrote: >> "ldries46" wrote in message >> news:57053167$0$4216$e4fe514c@news.kpn.nl... >> > How can I fin in which operating system a program runs and other details >> > of that operating system. >> >> Ada has System.System_Name provides an implementation-defined indication of >> the name of the target, but that often isn't set in any useful way. (Dunno >> what GNAT does with it, if anything.) > > With GNAT, I managed to make it work for Windows and Linux/Unix not long ago. > > Dir_Separator : Character; > pragma Import (C, Dir_Separator, "__gnat_dir_separator"); > --... > Put_Line ("The program is run on OS: => " & > (if Dir_Separator = '\' then "Windows" else "Unix/Linux")); GNAT.OS_Lib.Directory_Separator provides exactly this functionality.