ContentsIndexPreviousNext

C.1 Overview of Interface Methods

There are six USAGE types for integer data that simplify communications with other programming languages such as C. These types are designed to provide a portable method for handling machine-dependent data. For more information, see the Reference Manual, section 5.7.1.6 under "General Rules."

There are two methods, described below, to call subroutines written in the C language:

These methods may be used in combination with one another.

The direct method

The direct method allows you to pass arguments to C functions without writing special interfacing routines. Use this method when you want to simulate the behavior of a native code compiler. Parameters are passed directly to the C function according to the CALL statement that invoked the function, using the standard C calling conventions. This direct method simulates the actions of a native code compiler such as MicroFocus or VAX/COBOL.


Note: With the direct method, using BY VALUE causes the actual value to be passed to the routine (as expected). Using NULL will cause binary zeros to be passed to the routine (matching the NULL concept in C). With the direct method, passing a zero BY VALUE is much the same as specifying NULL (contrast this with the corresponding NOTE under the interface method described below).
The interface method

The interface method uses special routines that are passed the name of the called function. Use this method when you want to simulate the actions of a non-native system. ACUCOBOL-GT supports two types of interfaces for doing this. The two methods simulate interfaces available in two versions of RM/COBOL:

You may use either or both of these interfaces. With the interface method, parameters are passed to the interface routines in a standardized format. The parameters must typically be converted to a format that is usable in C.


Note: In the "sub85" and "sub" interface methods, parameters are not passed directly to the C routine. Instead, an array of pointers is passed, and each pointer points to the corresponding parameter (or in the case of "sub85," a description of the parameter). In this case, the notion of BY VALUE has no reasonable definition, because there is no place to put the value. Because of this, the runtime ignores the BY VALUE phrase and passes an address to a copy of the value (essentially treating BY VALUE as BY CONTENT). It must do this because there is no C variable available in which to pass the value. However, specifying NULL does have a reasonable definition--the pointer corresponding to that parameter is set to binary zeros. Therefore, with the interface method, NULL and BY VALUE ZERO have different meanings (contrast this with the corresponding NOTE under the direct method described above).
Both the direct method and the interface method require that you link the C routines into the runtime system. This process is described below.

In order to call C subroutines from ACUCOBOL-GT, you must have the appropriate C compiler for your host machine. This depends on the type of machine you are using.

Software Required

Microsoft Windows and Windows NT
--Microsoft Visual C++ version 6.0.

Extended MS-DOS
--Watcom C/C++ version 11.0.

OS/2
--IBM CSet++ for OS/2 version 2.1, or later.

UNIX
--The C compiler supplied by the vendor of your UNIX system. On some machines, this is supplied with UNIX. On others it is an add-on option.

VMS
--Digital Equipment Corporation's VAX C or DEC C compiler for VMS.

MPE/iX
--Hewlett Packard's C POSIX Developer's Kit.

No other software is required.

More:

C.1.1 Helpful Hints