Appendix F GNAT Ada The Gnat (GNU Ada Translator) project has developed a fully fledged Ada compiler that will work with the GNU linker. This will allow the compiler to be ported to any target that the GNU compiler/linker system is currently available for. The compiler is implementing the 1995 revision to the language, and so provides support for object oriented programming, enhanced concurrency support as well as numerous other features such as child and private child packages. The Gnat Ada compiler does away with the traditional library implementation of most Ada systems and presents a more traditional environment. Source code is compiled into a .o and a .ali file. The .o represents the translation of the instructions, the .ali file contains information about the relationship of the source to other components in the system. Gnat Ada source code must be in a file that has the same name as the compilation unit name, with either a .ads (for specifications) or a .adb (for bodies). Packages with child units (such as unix.file) should have the dot replaced with a '-', and the usual .ads or .adb suffix appended. For example the following program must be placed into a file called demo.adb. with simple_io; use simple_io; procedure demo is begin for i in 1..10 loop put("hello world"); new_line; end loop; end; To compile this you type in the following... gcc -c fred.adb Typical questions now asked at this stage... Do you mean that the C compiler actually compiles this program? Does this mean that the code is compiled to C? The answer to both of these questions is NO! gcc is not a compiler, it is a program that inspects the file suffix (e.g. .c, .adb, .ads, .c++) and then invokes the appropriate compiler. The gnat (GNu Ada Translator) compiles the program into the standard GNU intermediate code representation, which is then taken by the code generator specific for the computer you are running, and produces a normal '.o' object file. Now that that's out of the way... To link you program... gnatbl demo.ali It doesn't matter how many other procedures/packages you with, you don't need to specify them in the link option. However if you want to link in some C routines, then you may have to do the following (this example is taken from an example using the C curses library).... gnatbl demo.ali -lcurses Sharing software The Gnat compiler looks for the environment variables ADA_INCLUDE_PATH and ADA_OBJECT_PATH. Any directory in these path variables will be searched for source code and object code, respectively. In this way a group can share some commonly developed routines. Compiler source code (and source to all Ada standard packages) Currently on Arcadia/Yallara the source for the compiler and all the Ada standard packages are in the directory /opt/gnu/adainclude Some of these names have been 'crunched' (i.e. reduces to 8.3 DOS filename conventions) so it is not always immediately obvious where a package spec. resides. For example the text_io package can be found in the file a-textio.ads (ada.text_io package specification) Other packages of interest are... interfac.ads package Interface i-c.ads package Interface.C i-cpoint.ads package Interface.C.Pointers i-cstrin.ads pacakge Interface.C.Strings a-calend.ads package Calendar a-finali.ads package Ada.Finalization (for destructors etc) a-string.ads package Ada.Strings a-strbou.ads package Ada.Strings.Bounded