*GNAT - the GNU Ada Translator* - Ada 95/05 compiler, part of GCC
The Ada front end for GCC started out life outside of the FSF GCC tree as a projected funded by the (now defunct) Ada Joint Program Office (AJPO). In the 90's the AJPO funded NYU to develop an Ada 95 compiler. GNAT was merged into the FSF tree and became stable within that tree sometime in the late GCC 3.X series.
General information about Ada and to a large extent GNAT can be found at the wikibooks Ada page.
How do I download/install GNAT on my system?
- In many cases, it is either pre-installed on most Linux distrubutions or can be installed with the appropriate package management commands.
- Under CentOS 4.1
- yum install gcc-gnat - latest version is based on GCC 3.4.3
- Under Debian
- apt-get install gnat - (currenly installs a GCC 2.8.1 based on a patched version of GNAT 3.15p - not from FSF tree)
- apt-get install gnat-3.2 - installs a GCC 3.2 based Ada compiler
- apt-get install gnat-3.3 - installs a GCC 3.3 based Ada compiler
- apt-get install gnat-3.4 - installs a GCC 3.4 based Ada compiler
See The Debian Policy for Ada for more details.
- *Common Questions about GNAT*
- I understand Ada is supposed to have range checking for scalar types but I wrote a test program that I expected would generate an exception and did not get one. What happened?
- For a variety of reasons, GNAT requires a few non-default compiler flags to get Language Reference Manual(LRM) compliant performance. One can debate the wisdom of this approach but it it currently is what it is. In some cases, the default approach that was selected by the compiler developers is "better" than what is required by the LRM with few if any downsides. Try invoking the gnatmake command with the following options to get LRM compliant compiles
- gnatmake -gnato -fstack-check -gnatE my_program
- For a variety of reasons, GNAT requires a few non-default compiler flags to get Language Reference Manual(LRM) compliant performance. One can debate the wisdom of this approach but it it currently is what it is. In some cases, the default approach that was selected by the compiler developers is "better" than what is required by the LRM with few if any downsides. Try invoking the gnatmake command with the following options to get LRM compliant compiles
- Does GNAT generate C code? I hear it is a language translator.
No. GNAT does not and never did translate Ada code to C code. It translates Ada in the same way that the C front end translates C. Further adding to this confusion is the fact that earlier versions of GNAT did create a single .c file to call the elaboration code of each of the Ada packages but at no time was any of the user code translated into C.
- *What's new in GNAT?*
The Ada language standard is maintained by the International Organization for Standardization (ISO). While there are periodic clarifications released by the working group that maintains the language on a regular basis, these tend to be relatively minor (from a user's point of view) improvements to the language and standard library. The standard is however being updated with more substantial changes that will likely be formally documented in a new standard release within the next year. This is currently being called Ada 2005.
Many of the features of Ada 2005 are being rolled into GNAT.
- *See also*