Next: Pragma Extend_System, Previous: Pragma Export_Value, Up: Implementation Defined Pragmas
pragma Export_Valued_Procedure ( [Internal =>] LOCAL_NAME [, [External =>] EXTERNAL_SYMBOL] [, [Parameter_Types =>] PARAMETER_TYPES] [, [Mechanism =>] MECHANISM]); EXTERNAL_SYMBOL ::= IDENTIFIER | static_string_EXPRESSION | "" PARAMETER_TYPES ::= null | TYPE_DESIGNATOR {, TYPE_DESIGNATOR} TYPE_DESIGNATOR ::= subtype_NAME | subtype_Name ' Access MECHANISM ::= MECHANISM_NAME | (MECHANISM_ASSOCIATION {, MECHANISM_ASSOCIATION}) MECHANISM_ASSOCIATION ::= [formal_parameter_NAME =>] MECHANISM_NAME MECHANISM_NAME ::= Value | Reference | Descriptor [([Class =>] CLASS_NAME)] CLASS_NAME ::= ubs | ubsb | uba | s | sb | a
This pragma is identical to Export_Procedure
except that the
first parameter of LOCAL_NAME, which must be present, must be of
mode OUT
, and externally the subprogram is treated as a function
with this parameter as the result of the function. GNAT provides for
this capability to allow the use of OUT
and IN OUT
parameters in interfacing to external functions (which are not permitted
in Ada functions).
GNAT does not require a separate pragma Export
, but if none is
present, Convention Ada
is assumed, which is almost certainly
not what is wanted since the whole point of this pragma is to interface
with foreign language functions, so it is usually appropriate to use this
pragma in conjunction with a Export
or Convention
pragma that specifies the desired foreign convention.
Passing by descriptor is supported only on the OpenVMS ports of GNAT.
Special treatment is given if the EXTERNAL is an explicit null string or a static string expressions that evaluates to the null string. In this case, no external name is generated. This form still allows the specification of parameter mechanisms.