IBM i Global

IBM i 

A space for professionals working with IBM’s integrated OS for Power systems to exchange ideas, ask questions, and share expertise on topics like RPG and COBOL development, application modernization, open source integration, system administration, and business continuity.


#Power


#IBMi
 View Only
  • 1.  C++ Exports from User-Write *SRVPGM

    Posted Thu February 22, 2024 09:31 AM

    If I create a *MODULE from C++ source and in that C++ source I use a standard C/C++ runtime function, such as memcmp, when I bind that *SRVPGM to another *PGM object, when that *PGM objects C++ source code calls memcmp, it is referencing an export of memcmp from my user-written C++ module in my *SRVPGM and not to the C/C++ runtime service program export.

    I'm wondering how to prevent this from happening?



    ------------------------------
    Robert Cozzi
    ------------------------------


  • 2.  RE: C++ Exports from User-Write *SRVPGM

    Posted Fri March 01, 2024 09:43 AM

    While I can't be entirely sure without an example, one thing that comes to mind as a possible cause is to take a look at how your service program is being created. For example, are you using EXPORT(*SRCFILE) and specifying exactly what exports you want your service program to export, or are you using EXPORT(*ALL)?

    In general, I always recommend specifying the exports because it allows you to only export the functions you really want to export, and it gives you added benefits if you set it up correctly (in how you specify the signature) that you can even likely change your service program (for example to add more functionality), without needing to recompile programs that bind to it.



    ------------------------------
    Thanks,
    Brian Nordland
    Associate Director of Development at Fortra
    ------------------------------



  • 3.  RE: C++ Exports from User-Write *SRVPGM

    Posted Sun April 21, 2024 09:58 PM

    I too always use binder source and EXPORT(*SRCFILE), however for C++ that isn't possible when Class objects need to be exported. The only human codeable way to do that is, unfortunately EXPORT(*ALL) to get the C++ Classes exported correctly. 

    I have written a routine to generate the binder source for *MODULE once created, and then purge out some of the exports but its a never-ending task. 

    Sure with IBM i allowed a binder entry of a Class name that would export all of its stuff so we wouldn't need to code EXPORT(*ALL). But IBM told me to go pound sand on this one. :( 



    ------------------------------
    Robert Cozzi
    ------------------------------



  • 4.  RE: C++ Exports from User-Write *SRVPGM

    Posted Mon June 17, 2024 10:28 AM

    IBM should add the "visibility attribute" to the ILE C++ compiler which other C++ compilers are already using.

    Last year I had created an idea for that: https://ibm-power-systems.ideas.ibm.com/ideas/IBMI-I-3623



    ------------------------------
    Matthias Schatte
    ------------------------------