ILE C/C++ Programmer's Guide


Appendix B. Interlanguage Data-Type Compatibilities

Each high-level language (HLL) has different data types. When you want to pass data between programs written in different languages, you must be aware of these differences.

Some data types in the ILE C++ programming language have no direct equivalent in other languages. You can simulate data types in other languages using ILE C++ data types.

Notes:

  1. No data-type compatibility tables are shown for C. You can use the C++ tables because C and C++ data types are the same except for the packed decimal data type. For detailed information on using packed decimal data in ILE C/C++, see:

  2. In C++ the packed decimal data type is implemented as the bcd class. The packed decimal data type in ILE C and the binary coded decimal class in C++ are binary-compatible.

This appendix provides the following tables:

Table 37 shows the ILE C++ data-type compatibility with ILE CL.

Table 37. ILE C++ Data-Type Compatibility with ILE CL

ILE C++ declaration in prototype CL Length Comments
char[n]
char *
*CHAR LEN(&N) n An array of characters where n=1 to 32766. A null-terminated string. CHGVAR &V1 VALUE(&V *TCAT X'00') where &V1 is one byte bigger than &V
char *LGL 1 Holds '1' or '0'
_Packed struct {short i; char[n]} Not supported n+2 A variable length field where i is the intended length and n is the maximum length.
integer types Not supported 1, 2, 4 A 1, 2 or 4 byte signed or unsigned integer
float constants CL constants only 4 A 4 or 8 byte floating point
_DecimalT<n,p> *DEC n/2+1 A packed decimal. The limit of n is 15 and p is 9. In C++, this is a binary coded decimal class and not a data type.
union.element Not supported length of longest union member An element of a union
struct or class Not supported n A structure. The structure must be packed.1 Structures passed should be passed as a pointer to the structure if you want to change the contents of the structure.
pointer to function Not supported 16 A 16-byte pointer

Table 38 shows the ILE C++ data-type compatibility with CL.

Table 38. ILE C++ Data-Type Compatibility with CL

ILE C++ declaration in prototype CL Length Comments
char[n]
char *
*CHAR LEN(&N) n An array of characters where n=1 to 32766. A null-terminated string. CHGVAR &V1 VALUE(&V *TCAT X'00') where &V1 is one byte bigger than &V. The limit of n is 9999.
char *LGL 1 Holds '1' or '0'
_Packed struct {short i; char[n]} Not supported n+2 A variable length field where i is the intended length and n is the maximum length.
integer types Not supported 1, 2, 4 A 1, 2 or 4 byte signed or unsigned integer.
float constants CL constants only 4 A 4 or 8 byte floating point
_DecimalT<n,p> *DEC n/2+1 A packed decimal. The limit of n is 15 and p is 9. In C++, this is a binary coded decimal class and not a data type.
union.element Not supported length of longest union member An element of a union
struct or class Not supported n A structure. The structure must be packed.1 Structures passed should be passed as a pointer to the structure if you want to change the contents of the structure.
pointer to function Not supported 16 A 16-byte pointer

Table 39 shows the ILE C++ data type compatibility with ILE RPG.

Table 39. ILE C++ Data-Type Compatibility with ILE RPG

ILE C++ declaration in prototype ILE RPG D spec, columns 33 to 39 Length Comments
char[n] nA n An array of characters where n=1 to 32766
char * * 16 A pointer
char 1A 1 An indicator which is a variable starting with *IN
char[n] nS 0 n A zoned decimal
char[2n] nG 2n A graphic added
char[2n+2] Not supported 2n+2 A graphic data type
_Packed struct {short i; char[n]} data structure n+2 A variable length field where i is the intended length and n is the maximum length
char[n] D 8, 10 A date field
char[n] T 8 A time field
char[n] Z 26 A timestamp field
short int 5I 0 2 An integer field
short unsigned int 5U 0 2 An unsigned integer field
int 10I 0 4 An integer field
unsigned int 10U 0 4 An unsigned integer field
long int 10I 0 4 An integer field
long unsigned int 10I 0 4 An unsigned integer field
struct {unsigned int : n}x; Not supported 1, 2, 4 A 4-byte unsigned integer, a bitfield
float Not supported 4 A 4-byte floating point
double Not supported 8 An 8-byte floating point
long double Not supported 8 An 8-byte floating point
enum Not supported 1, 2, 4 Enumeration
_DecimalT<n,p> nP p n/2+1 A packed decimal. n must be less than or equal to 30. In C++, this is a binary coded decimal class and not a data type.
union.element <type> with keyword OVERLAY(longest field) length of longest union member An element of a union
data_type[n] <type> with keyword DIM(n) 16 An array to which C++ passes a pointer
struct or class data structure n A structure. The structure must be packed.1 Structures passed should be passed as a pointer to the structure if you want to change the contents of the structure.
pointer to function * with keyword PROCPTR 16 A 16-byte pointer
Note:
1All structures must be packed. Classes with virtual functions cannot be directly represented in any other language. Nested structures must be explicitly packed. In C, all nested structures are packed.

Table 40 shows the ILE C++ data-type compatibility with OPM RPG.

Table 40. ILE C++ Data-Type Compatibility with OPM RPG

ILE C++ declaration in prototype OPM RPG I spec, DS subfield columns spec Length Comments
char[n] 1 10 n An array of characters where n=1 to 32766
char *INxxxx 1 An indicator which is a variable starting with *IN
char[n] 1 nd (d>=0) n A zoned decimal The limit of n is 30
char[2n+2] Not supported 2n+2 A graphic data type
_Packed struct {short i; char[n]} Data structure n+2 A variable length field where i is the intended length and n is the maximum length.
char[n] char 6, 8, 10 A date field
char[n] char 8 A time field
char[n] char 26 A time stamp field.
short int B 1 20 2 A 2-byte signed integer with a range of -9999 to +9999
int B 1 40 4 A 4-byte signed integer with a range of -999999999 to +999999999
long int B 1 40 4 A 4-byte signed integer with a range of -999999999 to +999999999
struct {unsigned int : n}x; Not supported 1, 2, 4 A 4-byte unsigned integer, a bitfield
float Not supported 4 A 4-byte floating point
double Not supported 8 An 8-byte floating point
long double Not supported 8 An 8-byte floating point
enum Not supported 1, 2, 4 Enumeration
* Not supported 16 A pointer
_DecimalT<n,p> P 1 n/2+1d n/2+1 A packed decimal. n must be less than or equal to 30. In C++, this is a binary coded decimal class and not a data type.
union.element data structure subfield length of longest union member An element of a union
data_type[n] E-SPEC array 16 An array to which C++ passes a pointer
struct or class data structure n A structure. The structure must be packed.1 Structures passed should be passed as a pointer to the structure if you want to change the contents of the structure.
pointer to function Not supported 16 A 16-byte pointer
Note:
1All structures must be packed. Classes with virtual functions cannot be directly represented in any other language. Nested structures must be explicitly packed. In C, all nested structures are packed.

Table 41 shows the ILE C++ data-type compatibility with ILE COBOL.

Table 41. ILE C++ Data-Type Compatibility with ILE COBOL

ILE C++ declaration in prototype ILE COBOL LINKAGE SECTION Length Comments
char[n]
char *
PIC X(n). n An array of characters where n=1 to 3,000,000
char PIC 1 INDIC .. 1 An indicator
char[n] PIC S9(n) DISPLAY. n A zoned decimal
wchar_t[n] PIC G(n) DISPLAY. 2n A graphic data type
_Packed struct {short i; char[n]}
05 VL-FIELD.
  10 i PIC S9(4)
           COMP-4.
  10 data PIC X(n).
n+2 A variable length field where i is the intended length and n is the maximum length.
char[n] PIC X(n). 6 A date field
char[n] PIC X(n). 5 A day field
char PIC X. 1 A day-of-week-field
char[n] PIC X(n). 8 A time field
char[n] PIC X(n). 26 A time stamp field
short int PIC S9(4) COMP-4. 2 A 2-byte signed integer with a range of -9999 to +9999
short int PIC S9(4) BINARY. 2 A 2-byte signed integer with a range of -9999 to +9999
int PIC S9(9) COMP-4. 4 A 4-byte signed integer with a range of -999999999 to +999999999
int PIC S9(9) BINARY. 4 A 4-byte signed integer with a range of -999999999 to +999999999
int USAGE IS INDEX 4 A 4-byte integer
long int PIC S9(9) COMP-4. 4 A 4-byte signed integer with a range of -999999999 to +999999999
long int PIC S9(9) BINARY. 4 A 4-byte signed integer with a range of -999999999 to +999999999
struct {unsigned int : n}x;
PIC 9(9) COMP-4.
PIC X(4).
1, 2, 4 Bitfields can be manipulated using hex literals
float Not supported 4 A 4-byte floating point
double Not supported 8 An 8-byte floating point
long double Not supported 8 An 8-byte floating point
enum Not supported 1, 2, 4 Enumeration
* USAGE IS POINTER 16 A pointer
_DecimalT<n,p> PIC S9(n-p)V9(p) COMP-3. n/2+1 A packed decimal. In C++, this is a binary coded decimal class and not a data type.
_DecimalT<n,p> PIC S9(n-p) 9(p) PACKED-DECIMAL. n/2+1 A packed decimal. In C++ this is a binary coded decimal class not a data type.
union.element REDEFINES length of longest union member An element of a union
data_type[n] OCCURS n times the length of the data type An array to which C++ passes a pointer
struct or class OCCURS ...DEPENDING ON variable A structure. The structure must be packed.1 Structures passed should be passed as a pointer to the structure if you want to change the contents of the structure.
struct or class
01 record
   05 field1
   05 field2
n A structure. The structure must be packed.1 Structures passed should be passed as a pointer to the structure if you want to change the contents of the structure.
pointer to function PROCEDURE-POINTER 16 A 16-byte pointer to a procedure
Not supported. PIC S9(18) COMP-4. 8 An 8-byte integer
Not supported. PIC S9(18) BINARY. 8 An 8-byte integer
Note:
1All structures must be packed. Classes with virtual functions cannot be directly represented in any other language. Nested structures must be explicitly packed. In C, all nested structures are packed.

Table 42 shows the ILE C++ data-type compatibility with OPM COBOL.

Table 42. ILE C++ Data-Type Compatibility with OPM COBOL

ILE C++ declaration in prototype OPM COBOL LINKAGE SECTION Length Comments
char[n]
char *
PIC X(n). n An array of characters where n=1 to 3,000,000
char PIC 1 INDIC .. 1 An indicator
char[n] PIC S9(n) USAGE IS DISPLAY n A zoned decimal The limit of n is 18.
_Packed struct {short i; char[n]}
05 VL-FIELD.
  10 i PIC S9(4)
           COMP-4.
  10 data PIC X(n).
n+2 A variable length field where i is the intended length and n is the maximum length
char[n] PIC X(n). 6, 8, 10 A date field
char[n] PIC X(n). 8 A time field
char[n] PIC X(n). 26 A time stamp field
short int PIC S9(4) COMP-4. 2 A 2-byte signed integer with a range of -9999 to +9999.
int PIC S9(9) COMP-4. 4 A 4-byte signed integer with a range of -999999999 to +999999999
long int PIC S9(9) COMP-4. 4 A 4-byte signed integer with a range of -999999999 to +999999999
struct {unsigned int : n}x;
PIC 9(9) COMP-4.
PIC X(4).
1, 2, 4 Bitfields can be manipulated using hex literals.
float Not supported 4 A 4-byte floating point
double Not supported 8 An 8-byte floating point
long double Not supported 8 An 8-byte floating point
enum Not supported 1, 2, 4 Enumeration
* USAGE IS POINTER 16 A pointer
_DecimalT<n,p> PIC S9(n-p)V9(p) COMP-3. n/2+1 A packed decimal The limits of n and p are 18. In C++, this is a binary coded decimal class and not a data type.
union.element REDEFINES length of longest union member An element of a union
data_type[n] OCCURS n times the length of the data type An array to which C++ passes a pointer
struct or class OCCURS ...DEPENDING ON variable A structure. The structure must be packed.1 Structures passed should be passed as a pointer to the structure if you want to change the contents of the structure.
struct or class 01 record n A structure. The structure must be packed.1 Structures passed should be passed as a pointer to the structure if you want to change the contents of the structure.
pointer to function Not supported 16 A 16-byte pointer
Not supported. PIC S9(18) COMP-4. 8 An 8-byte integer
Note:
1All structures must be packed. Classes with virtual functions cannot be directly represented in any other language. Nested structures must be explicitly packed. In C all nested structures are packed.


[ Top of Page | Previous Page | Next Page | Table of Contents ]