Example 1. a mixture of C and C++

For this example, the following table shows the mapping of SCCNSAM data set members to given file names. The main program is provided to allow you to run the created DLL, it is not used in the following example.

SCCNSAM member name Name used in this example
CCNGID1 GlobInfo.h
CCNGID2 UserInt.h
CCNGID3 UserInterface.C
CCNGID4 c_DLL.c
CCNGID5 c_DLL.h
CCNGID6 cpp_DLL.C
CCNGID7 cpp_DLL.h
CCNGIDM main.C

This example involves the creation of a C/C++ DLL. The DLL is built from one C source file and two C++ source files. For your convenience, a main SCCNSAM(CCNGIDM) is provided so that the program can be executed. Instructions to build the main will not be given in this example. In general, IPA DLLs are created in the same manner as IPA modules with the extra commands for DLLs added in for the IPA link step.

Building example 1. under z/OS® UNIX System Services

First, IPA must compile each source file. Since NOOBJECT is the default, it is not specifically mentioned in this example. -WI is specified to trigger an IPA Compile.

c89 -c -2 -WI -Wc,"FLAG(I),DLL"  c_DLL.c
c++ -c -2 -WI -Wc,"FLAG(I)" -+ cpp_DLL.C
c++ -c -2 -WI -Wc,"FLAG(I),EXPORTALL" -+  UserInterface.C

If you are using the xlc utility, the same IPA Compile is invoked by the following command lines:

c89 -c -O2 -qipa -qflag=i -qdll          c_DLL.c
c++ -c -O2 -qipa -qflag=i             -+ cpp_DLL.C
c++ -c -O2 -qipa -qflag=i -qexportall -+ UserInterface.C

Next, the IPA link step is performed. In this case, IPA level(1) optimizations are used:

c++ -2  -WI,"LEVEL(1)" -Wl,I,DLL -Wl,DLL -o mydll
    UserInterface.o c_DLL.o cpp_DLL.o

The LEVEL(1) suboption is fed to IPA. The DLL option is given to the traditional optimizer using -Wl,I,DLL and the usual linker command for DLLs is given.

If you are using the xlc utility, the same IPA Link is invoked by the following command line:

c++ -O2  -qipa=level=1 -qdll -Wl,DLL -o mydll
  UserInterface.o c_DLL.o cpp_DLL.o

Building example 1. under batch

For this example, the following table shows the mapping of SCCNSAM data set members to given PDS member names. The main program is provided to allow you to run the created DLL, it is not used in the following example.

SCCNSAM member name Name used in this example
CCNGID1 IPA.H(GLOBINFO)
CCNGID2 IPA.H(USERINT)
CCNGID3 IPA.SOURCE(USERINT)
CCNGID4 IPA.SOURCE(CDLL)
CCNGID5 IPA.H(C@DLL)
CCNGID6 IPA.SOURCE(CPPDLL)
CCNGID7 IPA.H(CPP@DLL)
CCNGIDM IPA.SOURCE(MAIN)
//USERID1A JOB (127A,0329),'$MEM$',                                     
//  MSGLEVEL=(2,0),MSGCLASS=S,CLASS=A,                                  
//  NOTIFY=USERID1,REGION=1024M                                         
//PROC JCLLIB ORDER=(CBC.SCCNPRC)                          
//*-------------------------------------------------------------------- 
//* IPA compile step for CDLL                                           
//*-------------------------------------------------------------------- 
//C001F336  EXEC EDCC,                                                  
//          INFILE='USERID1.IPA.SOURCE(CDLL)',                          
//          OUTFILE='USERID1.IPA.OBJECT(CDLL),DISP=SHR',                
//          CPARM='OPTFILE(DD:OPTIONS)'                                 
//OPTIONS  DD *                                                         
    IPA(NOOBJECT) RENT LONG OPT(2) DLL                             
    LSEARCH('USERID1.IPA.+')                                             
    SEARCH('CEE.SCEEH.+')                                               
/*                                                                      
//*-------------------------------------------------------------------- 
//* IPA compile step for CPPDLL                                         
//*-------------------------------------------------------------------- 
//C001F336  EXEC CBCC,                                                  
//          INFILE='USERID1.IPA.SOURCE(CPPDLL)',                        
//          OUTFILE='USERID1.IPA.OBJECT(CPPDLL),DISP=SHR',              
//          CPARM='OPTFILE(DD:OPTIONS)'                                 
//OPTIONS  DD *                                                         
    IPA(NOOBJECT) OPT(2)                                           
    LSEARCH('USERID1.IPA.+')                                            
    SEARCH('CEE.SCEEH.+')                                               
/* 
//*-------------------------------------------------------------------- 
//* IPA compile step for USERINT                                        
//*-------------------------------------------------------------------- 
//C001F336  EXEC CBCC,                                                  
//          INFILE='USERID1.IPA.SOURCE(USERINT)',                       
//          OUTFILE='USERID1.IPA.OBJECT(USERINT),DISP=SHR',             
//          CPARM='OPTFILE(DD:OPTIONS)'                                 
//OPTIONS  DD *                                                         
    IPA(NOOBJECT) OPT(2) EXPORTALL                                 
    LSEARCH('USERID1.IPA.+')                                            
    SEARCH('CEE.SCEEH.+')                                   
/*                                                                      
//*-------------------------------------------------------------------- 
//* IPA link step for the hello module                                  
//*-------------------------------------------------------------------- 
//C001F336  EXEC CBCI,                                                  
//          OUTFILE='USERID1.IPALINK.OBJECT(MYDLL),DISP=SHR',           
//          IPARM='OPTFILE(DD:OPTIONS)'                                 
//* The following line sets up an input file that just includes all     
//*   the IPA compile step object files.                                
//SYSIN  DD DATA,DLM='/>'                                               
  INCLUDE OBJECT(USERINT,CDLL,CPPDLL)                                   
  INCLUDE SYSLIB(C128,IOSTREAM,COMPLEX)                                 
/>                                                                                                                                              
//* These are the options used                     
//OPTIONS  DD DATA,DLM='/>'                        
    IPA(LINK,MAP,LEVEL(1)) OPT(2) RENT LONGNAME    
/>                                                 
//* The following line gives the object library    
//OBJECT DD DSN=USERID1.IPA.OBJECT,DISP=SHR