www.delorie.com/gnu/docs/gcc/gnat_ug_189.html   search  
 
Buy the book!


Untitled Document

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

16.4.2 Using the Library

Libraries built as explained above can be used from any program, provided that the elaboration procedures (named mylibinit in the previous example) are called before the library services are used. Any number of libraries can be used simultaneously, as long as the elaboration procedure of each library is called.

Below is an example of C program that uses our mylib library.

 
#include "mylib_interface.h"

int
main (void)
{
   /* First, elaborate the library before using it */
   mylibinit ();

   /* Main program, using the library exported entities */
   do_something ();
   do_something_else ();

   /* Library finalization at the end of the program */
   mylibfinal ();
   return 0;
}

Note that this same library can be used from an equivalent Ada main program. In addition, if the libraries are installed as detailed in 16.2 Installing an Ada Library, it is not necessary to invoke the library elaboration and finalization routines. The binder will ensure that this is done as part of the main program elaboration and finalization phases.


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003