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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca.giganews.com!nntp.giganews.com!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Protected Type compiler complaint Date: Mon, 07 Jul 2014 08:55:24 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx05.eternal-september.org; posting-host="117da9042fa4d6f5956a9b8f72035635"; logging-data="6398"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Wg7UUeKemDFj9U1eUCqutkdf+ho/lMWg=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (darwin) Cancel-Lock: sha1:+DUGYdFZ3Mbg73oNWKQ8djp5H8Y= sha1:d3CCE6pBq3E9FWW9K+JYiSrnlhI= Xref: number.nntp.dca.giganews.com comp.lang.ada:187417 Date: 2014-07-07T08:55:24+01:00 List-Id: NiGHTS writes: > 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;