David - THANK YOU! I was about one "try this" away from bailing and writing a linkage stub in assembler.
I know "typedef is your friend." I started out with a typedef but at some point bailed on that approach because of the "extern must be at module level" issue. Just in case someone is searching this thread five years from now, the typedef actually needs a void in it: extern "OS" { typedef void (*entryPoint_t)(const char *record); } You can now see the direct BASR 14,15 in the generated code: 000139 | * (entryPoint)(record); 4400 C1AC 000139 | EX r0,HOOK..STMT 5800 D0C4 000139 | L r0,record(,r13,196) 5870 D0A8 000139 | L r7,entryPoint(,r13,168) A50A 8000 000139 | OILH r0,H'-32768' 4110 D098 000139 | LA r1,#MX_TEMP2(,r13,152) 5070 D098 000139 | ST r7,#MX_TEMP2(,r13,152) 5000 D09C 000139 | ST r0,#MX_TEMP2(,r13,156) 58F0 363A 000139 | L r15,1594(,r3) 4400 C1C0 000139 | EX r0,HOOK..CALLBGN 0DEF 000139 | BASR r14,r15 THANKS AGAIN! Charles -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of David Crayford Sent: Monday, July 16, 2012 9:57 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: How call from C++ thru function pointer to assembler? On 17/07/2012 11:35 AM, Charles Mills wrote: > David, thanks, will try again tomorrow. > > Does it perhaps want to factor differently? Perhaps something more > like > > (*extern "OS" entryPoint)(const char *); > > or something? Otherwise aren't you saying that the pointer itself is extern? What you need is a typedef extern "OS" { typedef (*entryPoint_t)(const char * arg); } entryPoint_t entryPoint = (entryPoint_t)cvt->entryPoint; > Don't let me confuse the issue -- it is not CSRSI that I am calling. > Header for CSRSI is in SYS1.SAMPLIB somewhere but is printed in the > callable services manual. They have something they call csrsi_byaddr > that looks exactly like what I am trying to accomplish but it is > bracketed with #ifndef __cplusplus which is what leads me to think > that perhaps this linkage is not supported for C++. I understand. If you are using a function pointer to a function that has not been loaded via fetch() then DLL(CBA) is required. Every function call in C++ is essentially a DLL call, so they require an FCB (function control block). There is overhead associated with DLL(CBA) so try to localize it to the module that calls the function. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN