IBM should add the "visibility attribute" to the ILE C++ compiler which other C++ compilers are already using.
Original Message:
Sent: Sun April 21, 2024 09:57 PM
From: Robert Cozzi
Subject: C++ Exports from User-Write *SRVPGM
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
Original Message:
Sent: Fri March 01, 2024 09:43 AM
From: Brian Nordland
Subject: C++ Exports from User-Write *SRVPGM
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
Original Message:
Sent: Thu February 22, 2024 09:31 AM
From: Robert Cozzi
Subject: C++ Exports from User-Write *SRVPGM
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
------------------------------