Operating System - HP-UX
1820882 Members
3493 Online
109628 Solutions
New Discussion юеВ

Re: ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

 
SOLVED
Go to solution
Chanquete
Occasional Advisor

ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

Hi people!
I've got this own library:
--------------------------------------------
Personal.h
--------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
#include
#include
#include
#include
....
MY_STREAM *wprintf(MY_STREAM *_this, const char *format, ...);
....
#ifdef __cplusplus
}
#endif
--------------------------------------------

Well, this function 'wprintf()' already exists in /usr/include/wchar.h. I can't change Personal.h, because is a customer's library.

I have problems when i try to compile a C++ program -my_program.C- (each one that includes Personal.h).

More, compiling it in a HP-UX B.11.11 PA_RISC (with CC compiler) it was OK. But now, compiling it in a HP-UX B.11.23 ITANIUM (with aCC) I obtain this error:
--------------------------------------------
"/usr/include/wchar.h", line 134: error #2338: more than one instance of overloaded function "wprintf" has "C" linkage
extern int wprintf __((const wchar_t *, ...));
^
--------------------------------------------
It could be a problem in the order of include files passing to the compiler, but i think it's fine.

I put down the logs of compiler (using option -v). I hope someone can help me.
Best regards!


--------------------------------------------
HP-UX B.11.11 PA-RISC (CC)
--------------------------------------------
/opt/CC/bin/CC -v
-D_HPUX_SOURCE -DHPUX -DHP9800 -DVERMAJOR=10 -DVERMINOR=0 -DSYSV -DMOTIF -DY2000 -DSPANIEN
+a1 -Aa +DAportable +DS1.1 +z -c /..../my_program.C
-I
/opt/langtools/lbin/cpp.ansi
-D_HPUX_SOURCE -DHPUX -DHP9800 -DVERMAJOR=10 -DVERMINOR=0 -DSYSV -DMOTIF -DY2000 -DSPANIEN
-I
-D__hp9000s700 -D_PA_RISC1_1 -$ -Z -Dc_plusplus -D__cplusplus -D__hp9000s800 -D__hppa -D__hpux -D__unix -Dhp9000s800
-Dhppa -Dhpux -Dunix -I/opt/CC/include/CC -I/usr/include /..../my_program.C /var/tmp/AAAa05164.i
/opt/CC/lbin/cfront +DAportable +DS1.1 +z +a1 +b1 +T/var/tmp/BAAa05164 +s +t/var/tmp/CAAa05164
+f/..../my_program.C +XCddp_data.o
--------------------------------------------
HP-UX B.11.23 ITANIUM (aCC)
--------------------------------------------
/opt/aCC/lbin/ecom -architecture 32 -ia64abi all -inst compiletime
-sysdir /usr/include -test namespaces -koenig_lookup on -ansi_for_scope on -inline_power 1 -link_type dynamic
-fpeval float -fpevaldec _Decimal32 -tls_dyn on -target_os 11.23

--sys_include /opt/aCC/include_std
--sys_include /opt/aCC/include_std/iostream_compat
--sys_include /usr/include --sys_include /usr -D_HP_IA64ABI -D_BIND_LIBCALLS -D_Math_errhandling=MATH_ERREXCEPT
-D__hpux -D__unix -D__ia64=1 -D__ia64__=1 -D_BIG_ENDIAN=1 -D__STDCPP__ -D_HP_NAMESPACE_STD -D_ILP32
-D__cplusplus=199711L -D_INCLUDE__STDC_A1_SOURCE -D__HP_aCC=62000 -D_HP_INSTANTIATE_T_IN_LIB -D_INLINE_ASM
-D_FLT_EVAL_METHOD=0 -D_DEC_EVAL_METHOD=0 -D_HPUX_SOURCE -DHPUX -DHP9800 -DVERMAJOR=10 -DVERMINOR=0 -DSYSV
-DMOTIF -DY2000 -DSPANIEN -ucode hdriver=optlevel%1% -plusolistoption -Ol06all! -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,ib,pl,sd,ll,rl,dl,
Lt,ol,fl,lm,ts,rd,dp,If!
/..../my_program.C

7 REPLIES 7
Chanquete
Occasional Advisor

Re: ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

Hi again, people.

If i comile my C++ program (in 11.23 ITANIUM machine) with 'aCC -Ae' i don't obtain the error.

Now i have an important existential doubt. In the previous machine (11.11 PA-RISC) i was compiling with 'cc -Aa' whit no errors. 'cc -Aa' is 'strict ANSI', and it seems to be a more securely option, is it? And i want to do this way in ITANIUM.
But, by the other side, the libraries and programs i was compiling are between 10 and 20 years ago, i can't change it (i do not want to change it). Furthermore, are in a 95% ANSI C source code, while other source code are C++.

With this info, what do you recommend to do?
'aCC -Aa' or 'aCC -Ae'?

Thanks so much in advance!
Dennis Handly
Acclaimed Contributor
Solution

Re: ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

#ifdef __cplusplus
extern "C" {
#endif
#include
#include

You must never ever put system include files in an extern "C" block! They are already C++ified.

>/opt/CC/bin/CC

This is the unsupported cfront compiler!

>it seems to be a more securely option, is it?

It might be better to use -AC99.

>With this info, what do you recommend to do?
'aCC -Aa' or 'aCC -Ae'?

You compile C with cc and C++ with aCC.

Note: If you want strict C89, you use "aCC -AC89", not -Aa. -Aa means something special in C++ mode.
Chanquete
Occasional Advisor

Re: ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

OK Dennis!

I'll try to fix programs to use only aCC, i'm working with very old source code and it will be very 'ugly' to do.

Best regards!
Dennis Handly
Acclaimed Contributor

Re: ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

>I'll try to fix programs to use only aCC

What are you trying to do? Compile old C++ source?

Ok, I read a little more closely.
It seems you have your own version of wprintf. This is illegal since wprintf is reserved in C99 and C++, 17.4.3.1.3(4).

You could put your wprintf in another namespace and then modify all of the callers.

You could use a macro to rename all of your uses to wprintf.

Or if you compile with -U_INCLUDE__STDC_A1_SOURCE it may make it go away.
Chanquete
Occasional Advisor

Re: ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

Hi again!

If i compile my C++ sources with '-U_INCLUDE__STDC_A1_SOURCE' option, everything is OK!!!

Can you give me a little explanation of this option? I guess it takes old std libraries, at least it takes the right libraries for my source code compatibility!

Thanks so much Dennis, although i gave you disorganized information, you could find the right solution!

Best wishes!
Dennis Handly
Acclaimed Contributor

Re: ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

>Can you give me a little explanation of this option?

The definition of wprintf in is under #ifdef _INCLUDE__STDC_A1_SOURCE.
Using -U undefines the driver default.
Chanquete
Occasional Advisor

Re: ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

You're great, man!

Thanks a lot!