1. If I code the declaration as extern "C" void (*entryPoint)(const SMFrecd *);
(did not try "OS" but it would have the same problem I think) then that is the declaration of an external function, not the definition of a pointer, right? In any event I get unresolved extern's on entryPoint at link time. There is no such syntax, I believe, as just "OS" without the extern. 2. It won't allow extern "C" (and again, I think extern "OS" would be the same) in the cast. It says "all linkage declarations must be at the module level" or something like that. Charles -----Original Message----- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of David Crayford Sent: Monday, July 16, 2012 6:09 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: How call from C++ thru function pointer to assembler? Why the __cdecl instead of extern OS? On 17/07/2012, at 8:34 AM, Charles Mills <charl...@mcn.org> wrote: > Wow! Fast answer, and looked very promising, but no change in behavior. > > Added DLL(CBA) to my options. > > Charles > > -----Original Message----- > From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] > On Behalf Of David Crayford > Sent: Monday, July 16, 2012 5:19 PM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: Re: How call from C++ thru function pointer to assembler? > > I suggest investigating the CALLBACKANY compiler option. > > On 17/07/2012, at 8:13 AM, Charles Mills <charl...@mcn.org> wrote: > >> Does anyone know the answer to this? >> >> I have an assembler function whose address I know at run-time in C++. >> I define and store it like this >> >> void __cdecl (*entryPoint)(const char *); entryPoint = (void (__cdecl >> *)(const char *))(myVoidStar); printf("entryPoint is %p\n", >> entryPoint); >> >> Printf prints the correct address (DFFD058, FWIW) so I am good so far. >> >> I then call it with >> (entryPoint)(record); >> >> and I end up S0C6ing out in the weeds at 27F5023B. >> >> Here is the pseudo-assembler from the C++ compiler. >> >> 4400 C1AC 000114 | EX r0,HOOK..STMT >> 5870 D0C0 000114 | L r7,record(,r13,192) >> 5810 D0C8 000114 | L r1,#CEECAACRENT_2(, >> 5880 35DA 000114 | L r8,=Q(entryPoint)(, >> 4118 1000 000114 | LA r1,=Q(entryPoint)(r >> 5810 1000 000114 | L r1,entryPoint(,r1,0 >> 58F0 1008 000114 | L r15,&EPA_&WSA(,r1,8 >> 5800 100C 000114 | L r0,&EPA_&WSA(,r1,12 >> 5000 C1F4 000114 | ST r0,_CEECAA_(,r12,50 >> 4110 D098 000114 | LA r1,#MX_TEMP2(,r13,1 >> 5070 D098 000114 | ST r7,#MX_TEMP2(,r13,1 >> 4400 C1C0 000114 | EX r0,HOOK..CALLBGN >> 0DEF 000114 | BASR r14,r15 >> 4400 C1C4 000114 | EX r0,HOOK..CALLRET >> >> Does anyone know what I should be declaring or doing differently? > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, send > email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN