Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Producing user routines in C

&pagelevel(3)&pagelevel

A C user routine which is produced from a single source can be stored as an LLM in a library without the need for a link stage. When loading the user routine, EDT specifies a "resolve context" which contains the required runtime modules.

The precise mechanism depends on whether or not EDT was initialized by a C main program with an ILCS flag:
If this is the case then user routines are loaded in a separate load context EDT#USER and the two load contexts EDT#CRTS and LOCAL#DEFAULT (in this sequence) are specified as the resolve context. As a result, external references to the C globals in the user routine are first resolved against the entries in EDT#CRTS (EDT runtime environment) and then against the entries in LOCAL#DEFAULT (C main program).
Since a (dynamically loadable) user routine is always called in the EDT runtime environment, the correct C globals are made available to the user routine irrespectively of whether the C main program itself possesses visible entries for the C globals.
The user routine's own load context must be taken into account if additional modules are to be dynamically loaded from within the user routine using BIND.

If the C main program has initialized EDT without an ILCS flag then, for reasons of compatibility, the user routine is loaded into the load context LOCAL#DEFAULT and EDT#CRTS is specified as the resolve context. In this case, the C main program should not have any visible entries to the C globals as otherwise these override the corresponding entries in the EDT runtime environment and the user routine is not able to work correctly with the C library functions.

The procedure below compiles and links C user routines which are stored as ANWEND1.C, ANWEND2.C, ... in the library EDT.BEISPIELE.
The generated LLM, the compiler lists and the diagnostic output are also stored in this library.

/SET-PROCEDURE-OPTIONS INPUT-FORMAT=FREE-RECORD-LENGTH,/
    DATA-ESCAPE-CHAR=STD
/BEGIN-PARAMETER-DECLARATION
/   DECLARE-PARAMETER NAME=NR
/   DECLARE-PARAMETER NAME=LIB,INITIAL-VALUE=C'EDT.BEISPIELE
/END-PARAMETER-DECLARATION
/START-CPLUS-COMPILER
//MODIFY-SOURCE-PROP LANGUAGE=*C
//MODIFY-RUNTIME-PROPERTIES PARAMETER-PROMPTING=*NO
//MODIFY-INCLUDE-LIBRARIES USER-INCLUDE-LIBRARY=//
    $.SYSLIB.EDT.170                   ------------------------------ (1)
//MODIFY-DIAGNOSTIC-PROPERTIES OUTPUT=*LIBRARY-ELEMENT(//
    LIB=&LIB,ELEM=*STD-ELEMENT()),//
    MIN-MSG-WEIGHT=*NOTE
//MODIFY-MODULE-PROPERTIES LOWER-CASE-NAMES=*YES,- 
//    SPECIAL-CHARACTERS=*KEEP           ------------------------------ (2)
//MODIFY-LISTING-PROPERTIES OUTPUT=*LIBRARY-ELEMENT(//
    LIB=&LIB,ELEM=*STD-ELEMENT()),SOURCE=*YES()
//COMPILE SOURCE=*LIB-ELEM(LIB=&LIB,ELEM=ANWEND&NR..C),-
//    MODULE-OUTPUT=*LIB-ELEM(LIB=&LIB,ELEM=ANWEND&NR)
//END
/EXIT-PROCEDURE

Explanations

(1)It is assumed that SYSLIB.EDT.170 is installed under the default user ID. The C compiler needs this library in order to locate the IEDTGLE interface header files.
(2)It should be possible to address the entries in the user routine under their original names. Consequently, lowercase characters must be accepted and special characters (such as "_") should not be changed.