Next: , Previous: Pragma CPP_Class, Up: Implementation Defined Pragmas


Pragma CPP_Constructor

Syntax:

     pragma CPP_Constructor ([Entity =>] LOCAL_NAME
       [, [External_Name =>] static_string_EXPRESSION ]
       [, [Link_Name     =>] static_string_EXPRESSION ]);

This pragma identifies an imported function (imported in the usual way with pragma Import) as corresponding to a C++ constructor. If External_Name and Link_Name are not specified then the Entity argument is a name that must have been previously mentioned in a pragma Import with Convention = CPP. Such name must be of one of the following forms:

where T is a limited record type imported from C++ with pragma Import and Convention = CPP.

The first two forms import the default constructor, used when an object of type T is created on the Ada side with no explicit constructor. The latter two forms cover all the non-default constructors of the type. See the GNAT User's Guide for details.

If no constructors are imported, it is impossible to create any objects on the Ada side and the type is implicitly declared abstract.

Pragma CPP_Constructor is intended primarily for automatic generation using an automatic binding generator tool (such as the -fdump-ada-spec GCC switch). See Interfacing to C++ for more related information.

Note: The use of functions returning class-wide types for constructors is currently obsolete. They are supported for backward compatibility. The use of functions returning the type T leave the Ada sources more clear because the imported C++ constructors always return an object of type T; that is, they never return an object whose type is a descendant of type T.