comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Drummond <brian@shapes.demon.co.uk>
Subject: Re: right compilation unit for C as main?
Date: Tue, 18 Dec 2012 15:28:12 +0000 (UTC)
Date: 2012-12-18T15:28:12+00:00	[thread overview]
Message-ID: <kaq22c$goh$1@dont-email.me> (raw)
In-Reply-To: b1d1bbac-0b53-4848-ae3c-92d85dc73df6@googlegroups.com

On Tue, 18 Dec 2012 07:02:25 -0800, Patrick wrote:

> Hello
> 
> I am trying to run concurrent Ada code bound to a C main.
> 
> I can get the Ada side to run if I explicitly call a procedure but I
> just want it to start running on adainit() and not block C untill it
> completes . I tried to write the Ada code inside a task but I ended up
> with an error that a task body is not a compilation unit.

adainit() should not block! It should set the environment up for Ada and 
return to your C main program. Which will then call an ...ahhh, Ada 
procedure which WILL block because the tasks it creates cannot outlive 
it...

So this Ada procedure must create your Ada tasks, and then execute a C 
function from its procedure body - your actual C code lives here.

But given this structure I don't see why you don't just use an Ada main.

> is there someway to have C main looping through C code and have an Ada
> task running or do I have to call C as a task? I would prefer to have C
> as main as some libraries seem to expect to be called from it.

If there is something odd about setting up some C libraries, then perhaps 
you can do this from a C main, then call the Ada procedure described 
above.

- Brian



  reply	other threads:[~2012-12-18 15:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-18 15:02 right compilation unit for C as main? Patrick
2012-12-18 15:28 ` Brian Drummond [this message]
2012-12-18 15:42   ` Patrick
2012-12-18 17:13   ` Robert A Duff
2012-12-18 23:04     ` Brian Drummond
2012-12-19  3:04     ` Simon Wright
2012-12-19  8:00       ` Niklas Holsti
2012-12-19 16:31       ` Robert A Duff
2012-12-18 17:14 ` Robert A Duff
replies disabled

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