COBOL Manual for TNS and TNS/R Programs
Calling Other Programs and Routines
HP COBOL Manual for TNS and TNS/R Programs—522555-006
23-26
Passing Parameters to Non-COBOL Routines
If a parameter is passed by reference so that the called routine can return a value to
the calling program, the parameter declaration must match the expectation of the
called routine, because HP COBOL code does not convert the values upon return from
the routine.
A COBOL program cannot pass a program name (a program-name in a PROGRAM-
ID paragraph) to a non-COBOL routine as a parameter.
Topics:
•
HP C or HP C++
•
FORTRAN
•
Pascal
•
TAL and pTAL
HP C or HP C++
In the large-memory model and the wide-data model, all pointers are 32 bits.
In both the non-CRE environment and the CRE:
•
A HP COBOL program can pass numeric arguments to an HP C or HP C++ routine
either by reference or by value.
•
A HP COBOL program must pass nonnumeric arguments to an HP C or HP C++
routine by reference.
•
If the data type of a value parameter differs from the data type of the corresponding
formal parameter, the compiler converts the value of the value parameter to the
data type of the formal parameter. If the value is outside the range of values
allowed for the HP C or HP C++ data type, an arithmetic trap occurs.
•
The compiler cannot convert reference parameters to different data types.
•
A HP COBOL program can pass an integer (NATIVE-2, NATIVE-4, or NATIVE-8)
data item to an HP C or HP C++ routine either as a reference parameter or by an
external declaration. In both cases, the HP C or HP C++ routine receives the
integer as a pointer type.
•
The GIVING phrase cannot be specified in an ENTER statement that accesses an
HP C or HP C++ function whose type is a pointer or whose type designation
includes the modifier “unsigned.” The type “char” is included in this prohibition,
because both the HP C compiler and the HP C++ compiler interpret it as
equivalent to the type “unsigned char.” The type “signed char” is acceptable.