Each high-level language has different data types. When you want to pass data between programs that are 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. However, you can simulate data types in other languages that use ILE C data types.
The following table shows the 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] char * |
|
n | An array of characters where n=1 to 32766. |
char |
|
1 | An Indicator that is a variable starting with *IN. |
char[n] |
|
n | A zoned decimal. |
char[2n] |
|
2n | A graphic added. |
char[2n+2] | Not supported. | 2n+2 | A graphic data type. |
_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. |
char[n] |
|
8, 10 | A date field. |
char[n] |
|
8 | A time field. |
char[n] |
|
26 | A timestamp field. |
short int |
|
2 | An integer field. |
short unsigned int |
|
2 | An unsigned integer field. |
int |
|
4 | An integer field. |
unsigned int |
|
4 | An unsigned integer field |
long int |
|
4 | An integer field. |
long unsigned int |
|
4 | An unsigned integer field. |
struct {unsigned int : n}x; | Not supported. | 4 | A 4-byte unsigned integer, a bitfield. |
float | Not supported. | 4 | A 4-byte floating point. |
double | Not supported. | 8 | An 8-byte double. |
long double | Not supported. | 8 | An 8-byte long double. |
enum | Not supported. | 1, 2, 4 | Enumeration. |
* |
|
16 | A pointer. |
decimal(n,p) |
|
n/2+1 | A packed decimal. n must be less than or equal to 30. |
union.element | <type> with keyword OVERLAY(longest field) | element length | An element of a union. |
data_type[n] | <type> with keyword DIM(n) | 16 | An array to which C passes a pointer. |
struct | data structure | n | A structure. Use the _Packed qualifier on the struct. |
pointer to function |
with keyword
PROCPTR |
16 | A 16-byte pointer. |
The following table shows the 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) | 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). |
4 | Bitfields can be manipulated using hex literals. |
float | Not supported. | 4 | A 4-byte floating point. |
double | Not supported. | 8 | An 8-byte double. |
long double | Not supported. | 8 | An 8-byte long double. |
enum | Not supported. | 1, 2, 4 | Enumeration. |
* | USAGE IS POINTER | 16 | A pointer. |
decimal(n,p) | PIC S9(n-p)V9(p) COMP-3 | n/2+1 | A packed decimal. |
decimal(n,p) | PIC S9(n-p) 9(p) PACKED-DECIMAL | n/2+1 | A packed decimal. |
union.element | REDEFINES | element length | An element of a union. |
data_type[n] | OCCURS | 16 | An array to which C passes a pointer. |
struct |
01 record 05 field1 05 field2 |
n | A structure. Use the _Packed qualifier on the struct. 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. |
The following table shows the 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. For example, 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. |
decimal(n,p) | *DEC | n/2+1 | A packed decimal. The limit of n is 15 and p is 9. |
union.element | Not supported. | element length | An element of a union. |
struct | Not supported. | n | A structure. Use the _Packed qualifier on the struct. |
pointer to function | Not supported. | 16 | A 16-byte pointer. |
The following table shows the ILE C data type compatibility with OPM RPG/400®.
ILE C declaration in prototype | OPM RPG/400 I spec, DS subfield columns spec | Length | Comments |
---|---|---|---|
char[n] char * |
1 10 | n | An array of characters where n=1 to 32766. |
char | *INxxxx | 1 | An Indicator that 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]} | Not supported. | n+2 | A variable length field where i is the intended length and n is the maximum length. |
char[n] | Not supported. | 6, 8, 10 | A date field. |
char[n] | Not supported. | 8 | A time field. |
char[n] | Not supported. | 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. | 4 | A 4-byte unsigned integer, a bitfield. |
float | Not supported. | 4 | A 4-byte floating point. |
double | Not supported. | 8 | An 8-byte double. |
long double | Not supported. | 8 | An 8-byte long double. |
enum | Not supported. | 1, 2, 4 | Enumeration. |
* | Not supported. | 16 | A pointer. |
decimal(n,p) | P 1 n/2+1d | n/2+1 | A packed decimal. n must be less than or equal to 30. |
union.element | data structure subfield | element length | An element of a union. |
data_type[n] | E-SPEC array | 16 | An array to which C passes a pointer. |
struct | data structure | n | A structure. Use the _Packed qualifier on the struct. |
pointer to function | Not supported. | 16 | A 16 byte pointer. |
The following table shows the ILE C data type compatibility with OPM COBOL/400.
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). |
4 | Bitfields can be manipulated using hex literals. |
float | Not supported. | 4 | A 4-byte floating point. |
double | Not supported. | 8 | An 8-byte double. |
long double | Not supported. | 8 | An 8-byte long double. |
enum | Not supported. | 1, 2, 4 | Enumeration. |
* | USAGE IS POINTER | 16 | A pointer. |
decimal(n,p) | PIC S9(n-p)V9(p) COMP-3 | n/2+1 | A packed decimal. The limits of n and p are 18. |
union.element | REDEFINES | element length | An element of a union. |
data_type[n] | OCCURS | 16 | An array to which C passes a pointer. |
struct | 01 record | n | A structure. Use the _Packed qualifier on the struct. 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. |
The following table shows the 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. For example, 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. |
decimal(n,p) | *DEC | n/2+1 | A packed decimal. The limit of n is 15 and p is 9. |
union.element | Not supported. | element length | An element of a union. |
struct | Not supported. | n | A structure. Use the _Packed qualifier on the struct. |
pointer to function | Not supported. | 16 | A 16-byte pointer. |
The following table shows how arguments are passed from a command line CL call to an ILE C program.
Command Line Argument | Argv Array | ILE C Arguments |
---|---|---|
argv[0] | "LIB/PGMNAME" | |
argv[1..255] | normal parameters | |
'123.4' | argv[1] | "123.4" |
123.4 | argv[2] | 0000000123.40000D |
'Hi' | argv[3] | "Hi" |
Lo | argv[4] | "LO" |
A CL character array (string) will not be NULL-ended when passed to an ILE C program. A C program that will receive such arguments from a CL program should not expect the strings to be NULL-ended. You can use the QCMDEXC to ensure that all the arguments will be NULL-ended.
The following table shows how CL constants are passed from a compiled CL program to an ILE C program.
Compile CL Program Argument | Argv Array | ILE C Arguments |
---|---|---|
argv[0] | "LIB/PGMNAME" | |
argv[1..255] | normal parameters | |
'123.4' | argv[1] | "123.4" |
123.4 | argv[2] | 0000000123.40000D |
'Hi' | argv[3] | "Hi" |
Lo | argv[4] | "LO" |
A command processing program (CPP) passes CL constants as defined in Table 28. You define an ILE C program as a command processing program when you create your own CL command with the Create Command (CRTCMD) command to call the ILE C program.
The following table shows how CL variables are passed from a compiled CL program to an ILE C program. All arguments are passed by reference from CL to C.
CL Variables | ILE C Arguments |
---|---|
DCL VAR(&v) TYPE(*CHAR) LEN(10) VALUE('123.4') | 123.4 |
DCL VAR(&d) TYPE(*DEC) LEN(10) VALUE(123.4) | 0000000123.40000D |
DCL VAR(&h) TYPE(*CHAR) LEN(10) VALUE('Hi') | Hi |
DCL VAR(&i) TYPE(*CHAR) LEN(10) VALUE(Lo) | LO |
DCL VAR(&j) TYPE(*LGL) LEN(1) VALUE('1') | 1 |
CL variables and numeric constants are not passed to an ILE C program with null-ended strings. Character constants and logical literals are passed as null-ended strings, but are not padded with blanks. Numeric constraints such as packed decimals are passed as 15,5 (8 bytes).