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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4d062d5c58234698 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.66.88.129 with SMTP id bg1mr376098pab.46.1355844492916; Tue, 18 Dec 2012 07:28:12 -0800 (PST) Path: s9ni51875pbb.0!nntp.google.com!news.glorb.com!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: right compilation unit for C as main? Date: Tue, 18 Dec 2012 15:28:12 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Injection-Date: Tue, 18 Dec 2012 15:28:12 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="dfff62e1e537b55df42008571c03e0fe"; logging-data="17169"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hBuhMpKppBmSWi4q5oYmimxsk8OPXirA=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:G/ahZJ5rmO2KARw+NKKBiz2JSYU= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Date: 2012-12-18T15:28:12+00:00 List-Id: 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