The following example uses the IPA control file to choose which functions should be exported from UserInterface.C. This allows the IPA compile step to be done without the EXPORTALL option. The first step is to construct an IPA control file. The function names appearing in the IPA control file must be mangled names if the names in the source file are going to be mangled by the compiler. The file content is as follows:
export=get_user_input__7UIclassFv,
get_user_sort_method__7UIclassFRi,
call_user_sort_method__7UIclassFi,
print_sort_result__7UIclassFv
Please refer to the appropriate sections of Example 1. a mixture of C and C++ to map the given names to the members of the SCCNSAM data set.
First, IPA must compile each source file using the following commands:
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)" -+ 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 -+ UserInterface.C
Next, the IPA link step is run to specify a control file:
c++ -2 -WI,"LEVEL(1),CONTROL(mydll.cntl)" -Wl,I,DLL -Wl,DLL -o mydll
UserInterface.o c_DLL.o cpp_DLL.o
If you are using the xlc utility, the same IPA Link is invoked by the following command line:
c++ -O2 -qipa=level=1 -qipa=control=mydll.cntl -qdll -Wl,DLL -o mydll
UserInterface.o c_DLL.o cpp_DLL.o
This creates a DLL where only the specified functions are exported from UserInterface.C.
//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)
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,LEVEL(1),CONTROL('USERID1.ipa.cntl(dllex)'))
OPT(2) RENT LONGNAME
/>
//* The following line gives the object library
//OBJECT DD DSN=USERID1.IPA.OBJECT,DISP=SHR
In the resultant object deck (MYDLL), only functions that are explicitly exported using #pragma export and the four functions given in the control file are exported.