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: border2.nntp.dca1.giganews.com!nntp.giganews.com!newspeer1.nac.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!weretis.net!feeder4.news.weretis.net!news.mixmin.net!news2.hunter.apana.org.au!brushtail.apana.org.au!eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Can .ads be compiled alone? Date: Thu, 06 Nov 2014 23:09:03 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <520f8f3d-b345-4ef8-ac41-ead78edde92a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Fri, 7 Nov 2014 06:08:56 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="e1e8835fd7030ec2a5463beff662d0eb"; logging-data="15492"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+DEI+bMLCZOGy3agG2Rxlz+V5mq6liIeg=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: <520f8f3d-b345-4ef8-ac41-ead78edde92a@googlegroups.com> Cancel-Lock: sha1:D2Lce8OZ0gJ7IzhRFTC5IEtEJEc= Xref: number.nntp.giganews.com comp.lang.ada:190358 Date: 2014-11-06T23:09:03-07:00 List-Id: On 11/06/2014 10:21 PM, moixa wrote: > > I have only two files, machinery_1_3.ads [1] and machinery_1_3.adb [2], in > some directory, when I `gnat compile machinery_1_3.ads`, it told me compile > error, (but no further information). > > A stackoverflow post[3] said that it's a good practice to separate compile > the spec and the body, so, why I cannot compile my .ads? This is an idiosyncrasy of GNAT's source-based compilation model. When you compile something that withs a package, GNAT also looks at the source file for the pkg spec. So GNAT normally only compiles a pkg body; typically the message when one tries to compile a spec that has a body is something like "cannot produce object code for a package specification" (I haven't tried it recently). You can check a pkg spec that has a body with -gnatc, and compile a spec that doesn't have a body, or compile a spec along with its body by compiling the body. Other compilers have other ways of dealing with this, and require that a pkg spec be compiled before you can compile something that withs it. -- Jeff Carter "In the frozen land of Nador they were forced to eat Robin's minstrels, and there was much rejoicing." Monty Python & the Holy Grail 70