3.2.9 Compiling Different Versions of Ada
The switches described in this section allow you to explicitly specify
the version of the Ada language that your programs are written in.
By default GNAT assumes Ada 2005,
but you can also specify Ada 95 or
indicate Ada 83 compatibility mode.
- -gnat83 (Ada 83 Compatibility Mode)
Although GNAT is primarily an Ada 95 / Ada 2005 compiler, this switch
specifies that the program is to be compiled in Ada 83 mode. With
-gnat83, GNAT rejects most post-Ada 83 extensions and applies Ada 83
semantics where this can be done easily.
It is not possible to guarantee this switch does a perfect
job; some subtle tests, such as are
found in earlier ACVC tests (and that have been removed from the ACATS suite
for Ada 95), might not compile correctly.
Nevertheless, this switch may be useful in some circumstances, for example
where, due to contractual reasons, existing code needs to be maintained
using only Ada 83 features.
With few exceptions (most notably the need to use
unconstrained generic formal parameters, the use of the new Ada 95 / Ada 2005
reserved words, and the use of packages
with optional bodies), it is not necessary to specify the
-gnat83 switch when compiling Ada 83 programs, because, with rare
exceptions, Ada 95 and Ada 2005 are upwardly compatible with Ada 83. Thus
a correct Ada 83 program is usually also a correct program
in these later versions of the language standard.
For further information, please refer to Compatibility and Porting Guide.
- -gnat95 (Ada 95 mode)
This switch directs the compiler to implement the Ada 95 version of the
Since Ada 95 is almost completely upwards
compatible with Ada 83, Ada 83 programs may generally be compiled using
this switch (see the description of the -gnat83 switch for further
information about Ada 83 mode).
If an Ada 2005 program is compiled in Ada 95 mode,
uses of the new Ada 2005 features will cause error
messages or warnings.
This switch also can be used to cancel the effect of a previous
-gnat83 or -gnat05 switch earlier in the command line.
- -gnat05 (Ada 2005 mode)
This switch directs the compiler to implement the Ada 2005 version of the
Since Ada 2005 is almost completely upwards
compatible with Ada 95 (and thus also with Ada 83), Ada 83 and Ada 95 programs
may generally be compiled using this switch (see the description of the
-gnat83 and -gnat95 switches for further
For information about the approved “Ada Issues” that have been incorporated
into Ada 2005, see http://www.ada-auth.org/ais.html.
Included with GNAT releases is a file features-ada0y that describes
the set of implemented Ada 2005 features.