comp.lang.ada
 help / color / mirror / Atom feed
From: "J-P. Rosen" <rosen@adalog.fr>
Subject: Re: Can .ads be compiled alone?
Date: Fri, 07 Nov 2014 07:20:52 +0100
Date: 2014-11-07T07:20:52+01:00	[thread overview]
Message-ID: <m3hobt$h8a$1@dont-email.me> (raw)
In-Reply-To: <520f8f3d-b345-4ef8-ac41-ead78edde92a@googlegroups.com>

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


  parent reply	other threads:[~2014-11-07  6:20 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-07  5:21 Can .ads be compiled alone? moixa
2014-11-07  6:09 ` Jeffrey Carter
2014-11-07 17:26   ` Robert A Duff
2014-11-07 17:41     ` Jeffrey Carter
2014-11-07  6:20 ` J-P. Rosen [this message]
2014-11-07  7:48 ` Chris Moore
2014-11-07 14:54   ` Tero Koskinen
2014-11-07 15:49     ` Björn Lundin
2014-11-07 16:29       ` G.B.
2014-11-08 13:01         ` moixa
2014-11-08 14:55           ` G.B.
2014-11-07 16:29       ` G.B.
2014-11-07 16:44     ` Adam Beneschan
2014-11-07 17:14   ` Shark8
2014-11-08 21:31     ` Chris Moore
2014-11-07 16:50 ` Adam Beneschan
2014-11-07 17:14   ` Robert A Duff
2014-11-08  2:01     ` Randy Brukardt
2014-11-15 12:54 ` rriehle
2014-11-15 19:17   ` Robert A Duff
2014-11-15 19:19     ` Robert A Duff
2014-11-17 15:52       ` Adam Beneschan
2014-11-17  0:07     ` rriehle
2014-11-17  6:50       ` Simon Wright
2014-11-24  3:16     ` rriehle
2014-11-24  6:34       ` Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox