Generating Ada Bindings for C and C++ headers (GNAT User’s Guide for Native Platforms)

#### 3.11.5 Generating Ada Bindings for C and C++ headers ¶

GNAT includes a binding generator for C and C++ headers, which is intended to do 95% of the tedious work of generating Ada specs from C or C++ header files.

This capability is not intended to generate 100% correct Ada specs and it will in some cases require you to make manual adjustments, although it can often be used out of the box in practice.

Some of the known limitations include:

- only very simple character constant macros are translated into Ada constants. Function macros (macros with arguments) are partially translated as comments, to be completed manually if needed.
- some extensions (e.g. vector types) are not supported
- pointers to pointers are mapped to `System.Address`
- identifiers with names that are identical except for casing may generate compilation errors (e.g. `shm_get` vs `SHM_GET`).

The code is generated using Ada 2012 syntax, which makes it easier to interface with other languages. In most cases, you can still use the generated binding even if your code is compiled using earlier versions of Ada (e.g. `-gnat95`).