Build and use a 64-bit application with IPA under z/OS® batch

Example: This example shows you how to IPA Compile both a C source file and a C++ source file in 64-bit mode, then IPA Link them, bind them (in 64-bit mode), and run the resulting load module.

This example also shows that when you want to create an IPA optimized program that makes use of calls to standard library functions, you need to explicitly let IPA know where to find the libraries that it will link with. The location of the standard library functions is not included by default in the IPA Link PROCs because if you do not actually ever call a standard library function, IPA will spend time analyzing the unused libraries before realizing your program does not need them, thereby unnecessarily slowing down your compilation time. If you are building a C++ program and do not tell IPA where to find the libraries it needs at IPA Link time, the IPA Linker will complain about the unresolved symbols it cannot find. You can tell IPA where the standard libraries are by adding the following lines to the CBCQI or EDCQI job steps in your JCL:
//SYSIN    DD DATA,DLM='/>'                 
 INCLUDE OBJECT(HELLO)
 INCLUDE SYSLIB(C64,IOSX64)               
 INCLUDE SYSLIB(CELQSCPP,CELQS003)        
/>                                        
//OBJECT   DD DSN=USER.TEST.OBJECT,DISP=SHR
Note: The USER.TEST.OBJECT data set and the HELLO PDS member are meant to represent the object file(s) for your application, which you should have created using a previous IPA compile step.
Example: The following example shows how to implement these instructions.
//USERID  JOB (641A,2317),'Programmer Name',REGION=128M,
//         CLASS=B,MSGCLASS=S,NOTIFY=&SYSUID;,MSGLEVEL=(1,1)
//ORDER JCLLIB ORDER=(CBC.SCCNPRC)
//*---------------------------------------------------------------------
//* 64-bit C IPA Compile
//*---------------------------------------------------------------------
//IPACOMP1 EXEC EDCC,
//         OUTFILE='USERID.IPA.LP64.OBJECT(OBJECT1),DISP=SHR',
//         CPARM='OPTFILE(DD:OPTIONS)'
//SYSIN    DD DATA,DLM='/>'

#include <time.h>
#include <string.h>
int get_time_of_day(char* output) {

  time_t     time_val;
  struct tm* time_struct;
  char*      time_string;


  if ( -1 != time(&time_val;) ) {

    time_struct = localtime(&time_val;);

    if ( NULL != time_struct ) {

      time_string = asctime(time_struct);

      if ( NULL != time_string ) {

        strcpy(output, time_string);
        output[strlen(output) - 1] = 0;

        return 0;		    
      }
    }
  }

  return 1;
}
/>
//OPTIONS  DD DATA,DLM='/>'
 IPA(NOOBJECT,NOLINK) LP64 LONGNAME OPT
/>
//*---------------------------------------------------------------------
//* 64-bit C++ IPA Compile with very high optimization
//*---------------------------------------------------------------------
//IPACOMP2 EXEC CBCC,
//         OUTFILE='USERID.IPA.LP64.OBJECT(OBJECT2),DISP=SHR',
//         CPARM='OPTFILE(DD:OPTIONS)'
//SYSIN    DD DATA,DLM='/>'

#include <iostream>
#include <string>

using std::cout;
using std::endl;
using std::string;

extern "C" int get_time_of_day(char*);

int main() {

  char* tod;

  tod = new char[100];

  if ( 0 == get_time_of_day(tod) ) {

    cout << "The current time is: " << tod << endl;

  } else {

    cout << "Error: Could not determine the time" << endl;

  }

  delete tod;

  return 0;
}
/>
//OPTIONS  DD DATA,DLM='/>'
 IPA(NOOBJECT,NOLINK) LP64 OPT(3)
/>
//*---------------------------------------------------------------------
//* 64-bit C++ IPA Link
//*---------------------------------------------------------------------
//IPALINK  EXEC CBCQI,
//         OUTFILE='USERID.IPALINK.LP64.OBJECT(IPAOBJ),DISP=SHR',
//         IPARM='IPA(LEVEL(2),MAP) LONGNAME'
//SYSIN    DD DATA,DLM='/>'                 
 INCLUDE OBJECT(OBJECT1)
 INCLUDE OBJECT(OBJECT2)
 INCLUDE SYSLIB(C64,IOSX64)               
 INCLUDE SYSLIB(CELQSCPP,CELQS003)        
/>                                        
//OBJECT   DD DSN=USERID.IPA.LP64.OBJECT,DISP=SHR
//*---------------------------------------------------------------------
//* C++ 64-bit Bind and Go Step
//*---------------------------------------------------------------------
//BINDGO   EXEC CBCQBG,
//         INFILE='USERID.IPALINK.LP64.OBJECT(IPAOBJ)',
//         OUTFILE='USERID.LP64.LOAD(FINALEXE),DISP=SHR'
//SYSIN    DD DATA,DLM='/>'
 INCLUDE OBJECT(IPAOBJ)
/>
//OBJECT   DD DSN=USERID.IPA.LP64.OBJECT,DISP=SHR