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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Can .ads be compiled alone? Date: Fri, 07 Nov 2014 07:20:52 +0100 Organization: A noiseless patient Spider Message-ID: References: <520f8f3d-b345-4ef8-ac41-ead78edde92a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 7 Nov 2014 06:20:45 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="2b3884a634d8f846e0712b4e3a92507a"; logging-data="17674"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Si8Kan9UaevUO71iFhyva" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 In-Reply-To: <520f8f3d-b345-4ef8-ac41-ead78edde92a@googlegroups.com> Cancel-Lock: sha1:AWnh9gV2FbhztyqcLG1g4XR2FoQ= Xref: news.eternal-september.org comp.lang.ada:23051 Date: 2014-11-07T07:20:52+01:00 List-Id: Le 07/11/2014 06:21, moixa a écrit : > 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? 1) Don't worry, your code is OK. If you have no error message, there is no error. 2) Explanation: This spurious message is an (unfortunate) consequence of the way gcc works. The gcc program is nothing but a driver that selects a front-end compiler according to the language, and a back-end code generator according to the target machine. Gnat is technically the front-end for the Ada language, the full compiler is gcc. There is no point in generating code if there are compile errors; therefore, if the front-end encounters any error, it returns a non-null exit status, and this will prevent gcc from activating the back-end. However, there is a special case in gnat (due to the so-called source model): when you compile a package spec, no code is generated; actually, you don't even need to compile package specs, since they are recompiled as part of the compilation of the body (although it is good practice to compile specs anyway, to check for errors as early as possible). The only way for Gnat to tell gcc that the back-end should not be launched in that case is to return a non-null exit code, which gcc interprets as a signal of a compilation error, and triggers the message. So, you can safely ignore it. HTH -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr