[Home] [Prev] [Next] [Index]
13.9 Interface to Other Languages
13.9 Interface to Other Languages
- 1
- A subprogram written in another language can be called from an Ada program provided that all communication is achieved via parameters and function results. A pragma of the form
- 2
-
pragma
INTERFACE (language_name, subprogram_name);
- 3
- must be given for each such subprogram; a subprogram name is allowed to stand for several overloaded subprograms. This pragma is allowed at the place of a declarative item, and must apply in this case to a subprogram declared by an earlier declarative item of the same declarative part or package specification. The pragma is also allowed for a library unit; in this case the pragma must appear after the subprogram declaration, and before any subsequent compilation unit. The pragma specifies the other language (and therby the calling conventions ) and informs the compiler that an object module will be supplied for the corresponding subprogram. A body is not allowed for such a subprogram (not even in the form of a body stub) since the instructions of the subprogram are written in another language.
- 4
- This capability need not be provided by all implementations. An implementation may place restrictions on the allowable forms and places of parameters and calls.
- 5
- Example:
package
FORT_LIB is
function
SQRT (X : FLOAT) return
FLOAT;
function
EXP (X : FLOAT) return
FLOAT;
private
pragma
INTERFACE(FORTRAN, SQRT);
pragma
INTERFACE(FORTRAN, EXP);
end
FORT_LIB;
- Notes:
- 6
- The conventions used by other language processors that call Ada programs are not part of the Ada language definition. Such conventions must be defined by these other language processors.
- 7
- The pragma INTERFACE is not defined for generic subprograms.
- 8
- References:

- allow 1.6

- body stub 10.2

- compilation unit 10.1

- declaration 3.1

- declarative item 3.9

- declarative part 3.9

- function result 6.5

- library unit 10.1

- must 1.6

- name 4.1

- overloaded subprogram 6.6

- package specification 7.1

- parameter of a subprogram 6.2

- pragma 2.8

- subprogram 6

- subprogram body 6.3

- subprogram call 6.4

- subprogram declaration 6.1
[Home] [Prev] [Next] [Index]
documentation@rational.com
Copyright © 1993-2000, Rational Software Corporation. All rights
reserved.