comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: right compilation unit for C as main?
Date: Tue, 18 Dec 2012 12:13:40 -0500
Date: 2012-12-18T12:13:40-05:00	[thread overview]
Message-ID: <wcc4njjtha3.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: kaq22c$goh$1@dont-email.me

Brian Drummond <brian@shapes.demon.co.uk> writes:

> 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...

That's true only if it declares objects containing tasks.
If it allocates objects containing tasks via "new",
with the access type declared at library level, then the
tasks can outlive their creator.

Tasks can also be created during library-package elaboration,
which is called from adainit.

> 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.

Using an Ada main is usually easier, but using a C main is
also possible, and sometimes necessary for reasons outside
the Ada world.

- Bob



  parent reply	other threads:[~2012-12-18 17:13 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
2012-12-18 15:42   ` Patrick
2012-12-18 17:13   ` Robert A Duff [this message]
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