Next: , Up: Building Mixed Ada & C++ Programs

2.11.1 Interfacing to C++

GNAT supports interfacing with the G++ compiler (or any C++ compiler generating code that is compatible with the G++ Application Binary Interface —see

Interfacing can be done at 3 levels: simple data, subprograms, and classes. In the first two cases, GNAT offers a specific Convention C_Plus_Plus (or CPP) that behaves exactly like Convention C. Usually, C++ mangles the names of subprograms. To generate proper mangled names automatically, see Generating Ada Bindings for C and C++ headers). This problem can also be addressed manually in two ways:

Interfacing at the class level can be achieved by using the GNAT specific pragmas such as CPP_Constructor. See Interfacing to C++, for additional information.