comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: some simple questions
Date: Sat, 22 Feb 2003 18:18:15 GMT
Date: 2003-02-22T18:18:15+00:00	[thread overview]
Message-ID: <3E57BF30.2090703@acm.org> (raw)
In-Reply-To: AmN5a.219205$Ec4.219339@rwcrnsc52.ops.asp.att.net

Steve wrote:
> 
> If you add:
>     procedure free is new ada.unchecked_deallocation( integer, pint );
> Then free(pi) works.

It seems more important to ask why the OP is using an access type. 
Pointers are needed far less often in Ada than in other languages; since 
the OP indicates that he knows [at least] one of these other languages, 
it is likely that this is a mind-set problem rather than a syntax question.

>>and last one
>>what's "std::system("clear");" translated to Ada
>>(OS Linux)
> 
> I can only guess on this one (you'll probably get an answer from someone
> else).
> Here's my guess:
>   If the profile for system looks something like:
>   int system( char *str );
> 
> Then in Ada you can use that function by declaring:
> 
>   function System( str : Interfaces.C.Strings.Char_Array_Access ) return
> integer;
>   pragma Import( C, System, "system" );

There's no need to use Char_Array_Access here; you can simply use 
Char_Array and the compiler will pass it correctly. You might want to 
avoid the name System, since it's the name of a standard package.

I have seen "system" imported and used successfully on Linux and 
Windows. You might also want to look for a compiler dependent package 
for access to the OS to do this. For example, GNAT provides the package 
GNAT.OS_Lib.

-- 
Jeff Carter
"Sons of a silly person."
Monty Python & the Holy Grail




      reply	other threads:[~2003-02-22 18:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-21 22:56 some simple questions Daniel Sch�le
2003-02-22  2:15 ` David C. Hoos, Sr.
2003-02-22  6:29   ` tmoran
2003-02-22 11:22 ` Preben Randhol
2003-02-22 11:57 ` chris.danx
2003-02-22 16:15 ` Steve
2003-02-22 18:18   ` Jeffrey Carter [this message]
replies disabled

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