The form of the
gnatbind command is
$ gnatbind [switches] mainprog[.ali] [switches]
where mainprog.adb is the Ada file containing the main program
gnatbind constructs an Ada
package in two files whose names are
b~mainprog.ads, and b~mainprog.adb.
For example, if given the
parameter hello.ali, for a main program contained in file
hello.adb, the binder output files would be b~hello.ads
When doing consistency checking, the binder takes into consideration
any source files it can locate. For example, if the binder determines
that the given main program requires the package
file is pack.ali and whose corresponding source spec file is
pack.ads, it attempts to locate the source file pack.ads
(using the same search path conventions as previously described for the
gcc command). If it can locate this source file, it checks that
the time stamps
or source checksums of the source and its references to in ALI files
match. In other words, any ALI files that mentions this spec must have
resulted from compiling this version of the source file (or in the case
where the source checksums match, a version close enough that the
difference does not matter).
The effect of this consistency checking, which includes source files, is that the binder ensures that the program is consistent with the latest version of the source files that can be located at bind time. Editing a source file without compiling files that depend on the source file cause error messages to be generated by the binder.
For example, suppose you have a main program hello.adb and a
P, from file p.ads and you perform the following
gcc -c hello.adbto compile the main program.
gcc -c p.adsto compile package
At this point, the file p.ali contains an out-of-date time stamp because the file p.ads has been edited. The attempt at binding fails, and the binder generates the following error messages:
error: "hello.adb" must be recompiled ("p.ads" has been modified) error: "p.ads" has been modified and must be recompiled
Now both files must be recompiled as indicated, and then the bind can succeed, generating a main program. You need not normally be concerned with the contents of this file, but for reference purposes a sample binder output file is given in Example of Binder Output File.
In most normal usage, the default mode of gnatbind which is to generate the main package in Ada, as described in the previous section. In particular, this means that any Ada programmer can read and understand the generated main program. It can also be debugged just like any other Ada code provided the -g switch is used for gnatbind and gnatlink.