Section 16.3 - Ada Bindings

The previous material should help you develop a "binding" (interface) between software components, where one component is written in Ada and another component is written in another language. Naturally, it's easier if someone else or a tool does the job for you.

Before you can evaluate what someone else has done, you need to understand the major types of bindings between an Ada program and another program. These types are called "direct" and "abstract":

Here are some other things you need to know about bindings:

Now that you understand these basic issues, you can go hunt for ways to make this interfacing job easier. The Ada Information Clearinghouse maintains a document listing existing Ada bindings for other products and standards. Their list is incomplete, but it's a good starting point, especially for common products or standards such as POSIX, X windows, Microsoft Windows, or SQL databases. If you're interfacing with a commercial product, ask the vendor to supply you with an Ada interface. You could also post a request to comp.lang.ada if you can't find what you're looking for.

There are also tools to automatically generate direct (thin) Ada bindings to C libraries. Here are two tools (there are others as well):

  1. Cbind translates C declarations and C preprocessor definitions into Ada package(s). Its strength is in ease-of-use; just type:
       "cbind file.h > file.ads".
    
    Cbind is available via Rational and Walnut Creek.

  2. CtoAda translates declarations from C to Ada. CtoAda's strength is that it provides many "hooks" to allow a programmer to control the translation. This gives more control at the expense of requiring more work by the programmer.

Quiz:


If you want to quickly create a binding to another language and don't mind that it might be a little clumsy to use, what kind of binding would you create?
  1. Direct ("thin") binding
  2. Abstract ("thick") binding

You may also:

PREVIOUS Go back to the previous section

NEXT     Skip to the next section

OUTLINE  Go up to the outline of lesson 16

David A. Wheeler (wheeler@ida.org)