========================================================================= G C O S - 8 C O B O L W O R K B E N C H v1.4.48 32bit RELEASE ========================================================================= VIRTUAL-C Support ================= TABLE OF CONTENTS ================= Introduction COBOL to Virtual-C interface Compiling Virtual-C subroutines Run-time configuration Test Virtual-C TPRs Limitations Introduction ============ G8WB provides support of Virtual-C subroutines, however a number of limitations apply, and special interfacing is also required. A C or C++ compiler (32-bit) is required. Visual C++ 6.0 has been used for the examples provided, however, any other compiler which has the ability to create a 32-bit DLL, can be used. Since G8WB is using dynamic linking, virtual-C subroutines cannot be linked with the COBOL application. By placing the subroutines into a Dynamic-Link-Library (DLL), these may be linked dynamically. A special interface is required, because the calling mechanism for COBOL and C is different, so to avoid changing the original COBOL source, a small interface module is used to 1) load the DLL and 2) adapt the call for interfacing with C. COBOL-85 Interface DLL *------------* *------------* *-----------* * CALL using * <-----> * CALL using * <-----> * subroutine* *------------* *------------* *-----------* COBOL to Virtual-C interface ============================ W8CHELLO.CBL provides an example of a COBOL to C interface, and it may be used as a template. You may build multiple interface modules or include all virtual-C interfaces in one module. Each virtual-C subroutines must be defined as an entry-point in the interface, however the subroutine name must be prefixed so it does not conflict with the original subroutine name, ex. entry "W8Chello_Chello" using lk-arg1 lk-arg2. Chello section. section-entry. move "Chello" to w8-called-name perform check-dll-load call WINAPI "CHello" using by content lk-arg1 by reference lk-arg2 . section-exit. exit program. If arguments are passed by reference (default), then a dummy argument description can be used, ex. 01 lk-arg2 pic x(01). for by content, you need to described the argument equivalent to the caller, ex. 01 lk-arg1 pic s9(9) comp-5. Note: COMP-6 becomes s9(9) comp-5. The interface module must be compiled as MF-Cobol, see COMP.BAT. Compiling Virtual-C subroutines =============================== CHello.CPP provides an example of a virtual-C subroutine, which has been included in the IntCHello workspace (for Visual C++). The virtual-C source is unchanged and you should normally not experience any compatibility error. IntCHello.CPP provides an example of a simple C stub, which is used to load the DLL from the Cobol to C interface module (W8CHello), and it may be used as a template. You may build multiple DLLs or all virtual-C subroutines in one DLL. extern void IntCHello(void); void IntCHello ( ) { return; } IntChello.DEF provides an example of a DLL definition file, which is used to name the entry-points within the DLL, and it may be used as a template. LIBRARY IntCHello DESCRIPTION "G8WB Library of C routines" EXPORTS IntCHello @1 CHello @2 Note: The C stub must first ordinal entry in the DLL. When building the workspace IntCHello, a DLL file is generated in either 'Release" or 'Debug' directory. Run-time configuration ====================== The use of a COBOL to C interface module, introduces a conflict since the original calling COBOL source use the name of the virtual-C subroutines, ex. CHello, whereas, G8WB requires the CALL to be redirected to a prefix entry-point, ex. W8Chello_CHello. You need to use EQUATE mapping to acomplish this redirection, ex. [common] "Chello" : "W8CHello_CHello" By including above entry in $G8WBGDIR\EQUATE.CFG, any call to "CHello" will be changed to "W8CHello_CHello". Remapping can be applied to any program via [COMMON] or to a specific program via [TCHELLO] tag. Equate mapping is NOT enabled by default, so you need either to enable this via $G8WBGDIR\PREP.CFG, ex. [DEFAULT-SECTION] EQUATE-MAPPING : ON or via a source directive, ex. *set>g8wb equate-mapping:ON IDENTIFICATION DIVISION. Note: Information message(s) document the equate actions taken during checking. Since the COBOL to C interface module utilize entry-points for each C subroutine interface, these cannot be found unless the interface module is loaded. You can pre-load the interface module through environment configuration in $G8WBGDIR\ENV.CFG, ex. [BATCH-SECTION] W8Chello [TP-SECTION] $somewhere\W8Chello The interface program is found through $COBDIR, or through a complete path if specified. The application DLL is found through $PATH, or through a complete path if specified in the interface program, ex. set ws-dll-ptr to entry "IntCHello.dll" or set ws-dll-ptr to entry "$somewhere\IntCHello.dll" Test ==== TCHello.CBL provides an example of a COBOL-85 program calling the simple virtual-C subroutine CHello. Virtual-C TPRs ============== G8WB does NOT support virtual-C TPRs, however it may be possible, depending on the complexity of such TPR, to implement a TPR shell in COBOL-85 and call the virtual-C logic as a subroutine. Note: VMPS and others GCOS8/TP8 service calls are NOT supported from virtual-C. Limitations =========== Besides the limitations described above, you may experience compatibility problem between GCOS8 virtual-C and the PC compiler selected. Should this occur, you are adviced to change you logic to make it compatible in both environments (ANSI). Naming: You cannot use the same name for COBOL to C interface mdoule and application DLL. ========================================================================= GCOS-8 COBOL Workbench is a trademark of B & C Solution Sarl. All other trademarks and trade names belong to their respective companies. ========================================================================= Copyright (C) 1991-2001 B & C Solution Sarl. All Rights Reserved.