|
Programming in C |
|
|
XCICS supports C programs that have been compiled using:
All the EXEC CICS commands available in COBOL and PL/I applications are also supported in C applications, with the exception of those commands related to nonstructured exception handling. Also note the following programming considerations: Exception handling Nonstructured exception handling The EXEC CICS commands related to nonstructured exception handling:
are not supported in C applications. Use of these commands is diagnosed by the translator. Condition handling In a C application, every EXEC CICS command is treated as if it had the NOHANDLE or RESP option specified. This means that the set of "system action" transaction abends that result from a condition occurring but not being handled, is not possible in a C or C++ application. Control always flows to the next instruction, and it is up to the application to test for a normal response. ABEND handling HANDLE ABEND PROGRAM commands are allowed, but you cannot use PUSH HANDLE or POP HANDLE. COMMAREA The address of the communication area is passed as an argument to a C main function. Of course, C functions can still use ADDRESS COMMAREA to obtain the address of the communications area. EIB The address of the EIB is passed as an argument to a C main function. Of course, C functions can still use ADDRESS EIB to obtain the address of the EIB. OVERFLOW conditions If you want any OVERFLOW condition to be indicated in the RESP field on return from a SEND MAP command with the ACCUM option, you should specify the NOFLUSH option. Return value If you terminate a C program with an exit() function or the return statement, instead of a CICS RETURN command, the value passed through the exit() function is saved in the EIBRESP2 field of the EIB on return from the program. Data declarations The following data declarations are provided by CICS for C:
The EIB declarations are enclosed in #ifndef and #endif lines, and are included in all translated files. Restrictions The following lists describe some of the restrictions that exist with C programs XCICS:
Passing arguments in C or C++ Arguments in C language are copied to the program stack at run time, where they are read by the function. These arguments can either be values in their own right, or they can be pointers to areas of memory that contain the data being passed. Passing a pointer is also known as passing a value by reference. Other languages, such as COBOL and PL/I, usually pass their arguments by reference, which means that the compiler passes a list of addresses pointing to the arguments to be passed. This is the call interface supported by CICS. To pass an argument by reference, you prefix the variable name with &, unless it is already a pointer, as in the case when an array is being passed. As part of the build process, the compiler may convert arguments from one data type to another. For example, an argument of type char may be converted to type short or type long. When you send values from a C program to XCICS, the translator takes the necessary action to generate code that results in an argument list of the correct format being passed to XCICS. The translator does not always have enough information to enable it to do this, but in general, if the argument is a single-character or halfword variable, the translator makes a precall assignment to a variable of the correct data type and passes the address of this temporary variable in the call. When you receive data from XCICS, the translator prefixes the receiving variable name with &, which causes the C compiler to pass it values by reference rather than by value (with the exception of a character string name, which is left unchanged). Without the addition of &, the compiler would copy the receiving variable and then pass the address of the copy to CICS. Any promotion occurring during this copying could result in data returned by CICS being lost. This table shows the rules that apply when passing values as arguments in EXEC CICS commands:
Note: Receiver is where data is being received from CICS; Sender is where data is being passed to CICS. Accessing the EIB The address of the exec interface block (EIB) is passed as an argument to a C main function. C and C++ functions can use the ADDRESS EIB command too, to obtain the address of the EIB. Addressability is achieved by using the command: EXEC CICS ADDRESS EIB(dfheiptr); Within a C application program, fields in the EIB are referred to in lower case and fully qualified as, for example, "dfheiptr->eibtrnid". The following mapping of data types is used:
Compiler considerations On some C compilers (i.e. IBM C for AIX 5.0), the 1 byte structure alignment, is not correctly handle. This causes errors when accessing BMS maps structures. The GNU GCC compiler (3.x or higher) actually works correctly on all the platforms where XFRAME is available, therefore it is the suggestes compiler for C language XCICS application development. |