Operating System - HP-UX
1751720 Members
5398 Online
108781 Solutions
New Discussion юеВ

Re: Issue compiling on Itanium related to passing function pointers.

 
ranganath_1
Occasional Advisor

Issue compiling on Itanium related to passing function pointers.

Hi, I am in process of migrating a C/C++ APP. from PA RISC HP-UX 11.11 to Itanium V23.

Thanks to help from Dennis and Andre, I overcame the issue with string class opened in my other thread.

Now I am stuck with a new compilation error with compiling function pointers. I am passing a function pointer (in this example svcPtr) to a third party software (bea tuxedo call) method - tpadvertise. The compiler throws error saying it is incompatible with parameter of type void *.

Greatly appreciate your help on this.

"TuxedoBroker.cpp", line 1189: error #2167: argument of type "AdFunction" is
incompatible with parameter of type "void (*)(TPSVCINFO *) C"
if(tpadvertise( (char *)serviceName.data(), svcPtr ) == TuxEvent::TUX_ERROR


Full compile command below:
Compiling TuxedoBroker.cpp
/opt/aCC/bin/aCC -g0 -AP -v -w +z +Z +Maked +DD32 +strict -I. -I./include -I/o
pt/siadev/rxrao61/SIA/common/include -I/opt/dbms/app/oracle/product/10.2_Client/
precomp/public -I/opt/dbms/app/oracle/product/10.2_Client/rdbms/demo -I/opt/tuxd
ir/tuxedo8.1/include -I/opt/siadev/slayer/include -I/usr/include -c TuxedoBroke
r.cpp -o obj/TuxedoBroker.o
/opt/aCC/lbin/ecom -architecture 32 -makedepend file --strict_warnings -ia64abi
all -diag off -inst compiletime -strict on -sysdir /usr/include -inline_power 1
-link_type dynamic -fpeval float -fpevaldec _Decimal32 -tls_dyn on -o obj/Tuxed
oBroker.o -target_os 11.23 -I. -I./include -I/opt/siadev/rxrao61/SIA/common/incl
ude -I/opt/dbms/app/oracle/product/10.2_Client/precomp/public -I/opt/dbms/app/or
acle/product/10.2_Client/rdbms/demo -I/opt/tuxdir/tuxedo8.1/include -I/opt/siade
v/slayer/include -I/usr/include --sys_include /opt/aCC/include --sys_include /op
t/aCC/include/iostream --sys_include /usr/include --sys_include /usr -D_HP_IA64A
BI -D_BIND_LIBCALLS -D_Math_errhandling=MATH_ERREXCEPT -D__hpux -D__unix -D__ia6
4=1 -D__ia64__=1 -D_BIG_ENDIAN=1 -D__STDCPP__ -D_ILP32 -D__cplusplus=199711L -D_
_HP_aCC=62000 -D_HP_INSTANTIATE_T_IN_LIB -D_INLINE_ASM -D_FLT_EVAL_METHOD=0 -D_D
EC_EVAL_METHOD=0 -debug debugG -ucode hdriver=optlevel%1% -plusolistoption -Ol06
all! -plusolistoption -Ol13moderate! -plusooption -Oq01,al,ag,cn,sz,ic,vo,Mf,Po,
es,rs,Rf,Pr,sp,in,cl,om,vc,pi,fa,pe,rr,pa,pv,nf,cp,lx,Pg,ug,lu,lb,uj,dn,sg,pt,kt
,em,np,ar,rp,dl,fs,bp,wp,pc,mp,lr,cx,cr,pi,so,Rc,fa,ft,fe,ap,st,lc,Bl,sr,Qs,do,i
b,pl,sd,ll,rl,dl,Lt,ol,fl,lm,ts,rd,dp,If! TuxedoBroker.cpp
"TuxedoBroker.cpp", line 1189: error #2167: argument of type "AdFunction" is
incompatible with parameter of type "void (*)(TPSVCINFO *) C"
if(tpadvertise( (char *)serviceName.data(), svcPtr ) == TuxEvent::TUX_ERROR
)



8 REPLIES 8
ranganath_1
Occasional Advisor

Re: Issue compiling on Itanium related to passing function pointers.

Hi, I have fixed this using an extern "C" construct around the function pointer typedef. Dont know if it will give runtime issues, but compile went through fine. Anyone can let me know if this is fine to do? At least compile works :-)
Steven Schweda
Honored Contributor

Re: Issue compiling on Itanium related to passing function pointers.

> Anyone can let me know if this is fine to do?

Perhaps someone who could see some of the
code would be able to guess better than I
can. Compiler commands and error messages
are nice, but seeing the actual source code
might be useful, too. Or am I missing
something obvious?
ranganath_1
Occasional Advisor

Re: Issue compiling on Itanium related to passing function pointers.

Here is the header decl. that I added the extern "C" to. This is a call to a third party vendor library - tpadvertise call. Also, I find that using -Aa option compiles this as is without need for extern "C"

extern "C" {
typedef void (*AdFunction)(TPSVCINFO *);
}

and the cpp file code that uses this:
void
TuxedoBroker::advertiseService( const string & serviceName, AdFunction svcPtr)
{
OSCMon().debugMsg("",OSCMONTRACEMSGLOWPRIORITY,
"TuxedoBroker::advertiseService - service: [%s]\n",
serviceName.data());

if(tpadvertise( (char *)serviceName.data(), svcPtr ) == TuxEvent::TUX_ERROR )
Steven Schweda
Honored Contributor

Re: Issue compiling on Itanium related to passing function pointers.

> Here is the header decl. that I added the
> extern "C" to. [...]

Is that in a header file supplied by the
people who supplied the library, or did you
create it yourself?


> incompatible with parameter of type "void (*)(TPSVCINFO *) C"

Did you notice the "C" in the error message?
I know nothing, but I find that suggestive.
ranganath_1
Occasional Advisor

Re: Issue compiling on Itanium related to passing function pointers.

I added the extern C in the header where I have typedef'ed this. THis is in my header.

Yes I noticed the C and was wondering if that was becasue this is a C typedef and that is why i added the extern "C"

but using -Aa also works without the extern "C"
Steven Schweda
Honored Contributor

Re: Issue compiling on Itanium related to passing function pointers.

> THis is in my header.

Didn't they give you a header file to use?
(And doesn't it have this stuff in it
already?)
ranganath_1
Occasional Advisor

Re: Issue compiling on Itanium related to passing function pointers.

I need to define the function pointer on my side and pass it to their call. This is the way it is works on hp-ux 11.11 without issues
Dennis Handly
Acclaimed Contributor

Re: Issue compiling on Itanium related to passing function pointers.

Since we don't know what AdFunction or tpadvertise is, you'll have to show us.

>I have fixed this using an extern "C" construct around the function pointer typedef.

This is the correct solution. If you use +strict, you are asking for error when you violate the C vs C++ linkage of pointers to functions.

>Don't know if it will give runtime issues. Anyone can let me know if this is fine to do?

On our implementation, the linkage is the same.

>I find that using -Aa option compiles this as is without need for extern "C"

This shouldn't make a difference, only +strict.

>I need to define the function pointer on my side and pass it to their call.

They should be giving you the prototype of advertiseService or tpadvertise and that should have a typedef for that pointer to function.

>aCC -AP

If you are going to use +strict, you shouldn't be using -AP, use -AA.

>Steven: Or am I missing something obvious?

Yes, if you have had to fix a bunch of these errors, you would know. :-)

>Did you notice the "C" in the error message? but I find that suggestive.

Exactly.