A.11. Mixed Language Programming

You build a program that contains some Ada files and some other language files in one of two ways, depending on whether the main program is in Ada or not. If the main program is in Ada, you proceed as follows:

  1. Compile the Ada units to produce a set of object files and ALI files.

  2. Compile the other language files to generate object files.

  3. Run the Ada binder on the Ada main program.

  4. Compile the Ada main program.

  5. Link the Ada main program, Ada objects and other language objects.

If the main program is in some language other than Ada, you use a special option of the binder to generate callable routines to initialize and finalize the Ada units. You must insert calls to these routines in the main program, or some other appropriate point. The call to initialize the Ada units must occur before the first Ada subprogram is called, and the call to finalize the Ada units must occur after the last Ada subprogram returns. You use the same procedure for building the program as described previously. In this case, however, the binder places the initialization and finalization subprograms into file b_xxx.c instead of the main program.