From: NiGHTS <nights@unku.us>
Subject: Re: Protected Type compiler complaint
Date: Mon, 7 Jul 2014 07:23:32 -0700 (PDT)
Date: 2014-07-07T07:23:32-07:00 [thread overview]
Message-ID: <35cd9c91-4b2c-4baa-9ef6-3c69fd7086ce@googlegroups.com> (raw)
In-Reply-To: <lyk37peh77.fsf@pushface.org>
On Monday, July 7, 2014 3:55:24 AM UTC-4, Simon Wright wrote:
> > When I compile it complains that "protected declaration cannot be used
>
> > as compilation unit" on line 1 of test.ads. So I remove those files
>
> > from the project source files options menu. Then when I compile again
>
> > it complains about "test.ads not found" on line 3 of main.adb.
>
>
>
> A protected declaration cannot be used as a compilation unit; it has to
>
> be declared within one.
>
>
>
> > Here is a summarized view of what my test.ads looks like:
>
> >
>
> > protected type Test is procedure DoSomething; end Test;
>
>
>
> package Test is
>
> protected type P is
>
> procedure Do_Something;
>
> end P;
>
> end Test;
>
>
>
> > And here is a summarized view of what my main.adb looks like:
>
> >
>
> > with Test; use Test;
>
> >
>
> > procedure main is begin Test.DoSomething; end;
>
>
>
> You made Test a protected *type* (and I've suggested Test.P), so you
>
> need to declare a protected *object* of that type.
>
>
>
> with Test;
>
> procedure Main is
>
> O : Test.P;
>
> begin
>
> O.Do_Something;
>
> end Main;
Thank you for your help. This makes sense.
A question about the variables in the Test.P type you introduced. I would like to make available to other spawned tasks these protected variables, so essentially Test.P needs to be a global of some kind with static data in the currently running process. I heard much about not creating global variables for good Ada coding practice, so how is this protected package variables expected to be usable by these spawned tasks?
NOTE: The task code may not be directly associated to the main package as I expect to create task utility packages shared by multiple applications.
Thank you again for your help.
next prev parent reply other threads:[~2014-07-07 14:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-07 7:15 Protected Type compiler complaint NiGHTS
2014-07-07 7:55 ` Simon Wright
2014-07-07 14:23 ` NiGHTS [this message]
2014-07-07 16:37 ` Adam Beneschan
2014-07-07 17:21 ` Simon Wright
2014-07-08 17:03 ` Shark8
2014-07-08 17:50 ` Anh Vo
2014-07-07 19:06 ` framefritti
2014-07-08 7:11 ` Georg Bauhaus
2014-07-08 7:53 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox