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

Pragma Export_Function


     pragma Export_Function (
          [Internal         =>] LOCAL_NAME
       [, [External         =>] EXTERNAL_SYMBOL]
       [, [Parameter_Types  =>] PARAMETER_TYPES]
       [, [Result_Type      =>] result_SUBTYPE_MARK]
       [, [Mechanism        =>] MECHANISM]
       [, [Result_Mechanism =>] MECHANISM_NAME]);
     | static_string_EXPRESSION
     | ""
     | subtype_Name ' Access
     MECHANISM ::=
       [formal_parameter_NAME =>] MECHANISM_NAME
     | Reference
     | Descriptor [([Class =>] CLASS_NAME)]
     | Short_Descriptor [([Class =>] CLASS_NAME)]
     CLASS_NAME ::= ubs | ubsb | uba | s | sb | a

Use this pragma to make a function externally callable and optionally provide information on mechanisms to be used for passing parameter and result values. We recommend, for the purposes of improving portability, this pragma always be used in conjunction with a separate pragma Export, which must precede the pragma Export_Function. GNAT does not require a separate pragma Export, but if none is present, Convention Ada is assumed, which is usually not what is wanted, so it is usually appropriate to use this pragma in conjunction with a Export or Convention pragma that specifies the desired foreign convention. Pragma Export_Function (and Export, if present) must appear in the same declarative region as the function to which they apply.

internal_name must uniquely designate the function to which the pragma applies. If more than one function name exists of this name in the declarative part you must use the Parameter_Types and Result_Type parameters is mandatory to achieve the required unique designation. subtype_marks in these parameters must exactly match the subtypes in the corresponding function specification, using positional notation to match parameters with subtype marks. The form with an 'Access attribute can be used to match an anonymous access parameter.

Passing by descriptor is supported only on the OpenVMS ports of GNAT. The default behavior for Export_Function is to accept either 64bit or 32bit descriptors unless short_descriptor is specified, then only 32bit descriptors are accepted.

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.