comp.lang.ada
 help / color / mirror / Atom feed
* How to find the type of operating system.
@ 2016-04-06 15:55 ldries46
  2016-04-06 21:41 ` Randy Brukardt
  2016-04-07 11:20 ` Lucretia
  0 siblings, 2 replies; 8+ messages in thread
From: ldries46 @ 2016-04-06 15:55 UTC (permalink / raw)


How can I fin in which operating system a program runs and other details of 
that operating system. 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to find the type of operating system.
  2016-04-06 15:55 How to find the type of operating system ldries46
@ 2016-04-06 21:41 ` Randy Brukardt
  2016-04-06 22:42   ` Anh Vo
  2016-04-07 11:20 ` Lucretia
  1 sibling, 1 reply; 8+ messages in thread
From: Randy Brukardt @ 2016-04-06 21:41 UTC (permalink / raw)


"ldries46" <bertus.dries@planet.nl> 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.)

So I would say that essentially Ada provides no such information. Of course, 
individual Ada packages provide some information about the target system 
(System.Tick which gives info about Calendar.Time, various functions in 
Ada.Directories give info about the file system, etc.)

                                     Randy.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to find the type of operating system.
  2016-04-06 21:41 ` Randy Brukardt
@ 2016-04-06 22:42   ` Anh Vo
  2016-04-07  6:45     ` Simon Wright
  0 siblings, 1 reply; 8+ messages in thread
From: Anh Vo @ 2016-04-06 22:42 UTC (permalink / raw)


On Wednesday, April 6, 2016 at 2:41:33 PM UTC-7, Randy Brukardt wrote:
> "ldries46" <bertus.dries@planet.nl> 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"));

Anh Vo

 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to find the type of operating system.
  2016-04-06 22:42   ` Anh Vo
@ 2016-04-07  6:45     ` Simon Wright
  2016-04-07  7:31       ` Randy Brukardt
  0 siblings, 1 reply; 8+ messages in thread
From: Simon Wright @ 2016-04-07  6:45 UTC (permalink / raw)


Anh Vo <anhvofrcaus@gmail.com> writes:

> On Wednesday, April 6, 2016 at 2:41:33 PM UTC-7, Randy Brukardt wrote:
>> "ldries46" <bertus.dries@planet.nl> 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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to find the type of operating system.
  2016-04-07  6:45     ` Simon Wright
@ 2016-04-07  7:31       ` Randy Brukardt
  2016-04-07 16:33         ` Jeffrey R. Carter
  0 siblings, 1 reply; 8+ messages in thread
From: Randy Brukardt @ 2016-04-07  7:31 UTC (permalink / raw)


"Simon Wright" <simon@pushface.org> wrote in message 
news:lyoa9ludbf.fsf@pushface.org...
> Anh Vo <anhvofrcaus@gmail.com> writes:
>
>> On Wednesday, April 6, 2016 at 2:41:33 PM UTC-7, Randy Brukardt wrote:
>>> "ldries46" <bertus.dries@planet.nl> 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.

Presumably you could get that value from a suitable use of 
Ada.Directories.Compose, which would eliminate the 
implementation-definedness for at least that check. But what you'd decide on 
VMS I'm not sure. :-)

                                     Randy.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to find the type of operating system.
  2016-04-06 15:55 How to find the type of operating system ldries46
  2016-04-06 21:41 ` Randy Brukardt
@ 2016-04-07 11:20 ` Lucretia
  2016-06-24 21:12   ` Victor Porton
  1 sibling, 1 reply; 8+ messages in thread
From: Lucretia @ 2016-04-07 11:20 UTC (permalink / raw)


On Wednesday, 6 April 2016 16:55:51 UTC+1, ldries46  wrote:
> How can I fin in which operating system a program runs and other details of 
> that operating system.

You know what OS you're compiling on, so define a variable in GPR OS and set it on compile. During compile, set the source dirs to include an os specific one and in there put a package which defines the OS:

package OS is
   type OSes is (Linux, Windows, MacOS, iOS, etc.);

   This : OSes := Linux; --  For the linux/os.ads file.
end OS;


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to find the type of operating system.
  2016-04-07  7:31       ` Randy Brukardt
@ 2016-04-07 16:33         ` Jeffrey R. Carter
  0 siblings, 0 replies; 8+ messages in thread
From: Jeffrey R. Carter @ 2016-04-07 16:33 UTC (permalink / raw)


On 04/07/2016 12:31 AM, Randy Brukardt wrote:
> "Simon Wright" <simon@pushface.org> wrote in message
> news:lyoa9ludbf.fsf@pushface.org...
>> Anh Vo <anhvofrcaus@gmail.com> writes:
>>>
>>> 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.
>
> Presumably you could get that value from a suitable use of
> Ada.Directories.Compose, which would eliminate the
> implementation-definedness for at least that check. But what you'd decide on
> VMS I'm not sure. :-)

Clearly, "Unix/Linux".

-- 
Jeff Carter
"They name the boy Jonathan Ralph Starkwell,
after Virgil's mother."
Take the Money and Run
141


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to find the type of operating system.
  2016-04-07 11:20 ` Lucretia
@ 2016-06-24 21:12   ` Victor Porton
  0 siblings, 0 replies; 8+ messages in thread
From: Victor Porton @ 2016-06-24 21:12 UTC (permalink / raw)


Lucretia wrote:

> On Wednesday, 6 April 2016 16:55:51 UTC+1, ldries46  wrote:
>> How can I fin in which operating system a program runs and other details
>> of that operating system.
> 
> You know what OS you're compiling on, so define a variable in GPR OS and
> set it on compile. During compile, set the source dirs to include an os
> specific one and in there put a package which defines the OS:
> 
> package OS is
>    type OSes is (Linux, Windows, MacOS, iOS, etc.);
> 
>    This : OSes := Linux; --  For the linux/os.ads file.
> end OS;

You've forgotten to add "constant" keyword for "This" object.

-- 
Victor Porton - http://portonvictor.org


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-06-24 21:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-06 15:55 How to find the type of operating system ldries46
2016-04-06 21:41 ` Randy Brukardt
2016-04-06 22:42   ` Anh Vo
2016-04-07  6:45     ` Simon Wright
2016-04-07  7:31       ` Randy Brukardt
2016-04-07 16:33         ` Jeffrey R. Carter
2016-04-07 11:20 ` Lucretia
2016-06-24 21:12   ` Victor Porton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox