Re: multiple definitions of 'vsnprintf'
Keith Marshall <[email protected]>
| Newsgroups | gmane.comp.gnu.mingw.user |
|---|---|
| Organization | MinGW.org Project |
| Message-ID | <[email protected]> |
On 31/07/19 19:36, Laura Yindra wrote:
> I am getting the error:
> libmingwex.a(vsnprintf.o):(.text+0x0): multiple definition of
> 'vsnprintf'; main.cpp:(.text$vsnprintf[_nsvprintf]+0x0): first defined
> here collect2.exe: error: ld returned 1 exit status
Thank you for bringing this to my attention. I can confirm that there
is a reproducible problem here; however ...
> the contents of main.cpp are
> #include <string>
> #include <iostream>
> int main(void)
> {
> std::cout << "Hello World. "<<std::to_string(1)<<std::endl;
> return 0;
> }
>
> the command I am executing in msys.bat is
> g++ -std=c++11 main.cpp
>
> I only get this error when mingw32-gcc-g++ version is 8.2.0-4
> This error is not in mingw32-gcc-g++ version 6.3.0-1
... the GCC version is not pertinent. Yes, like you, I see the problem
when compiling your test case with GCC-8.2.0, and (initially) I do not
see it with either GCC-6.3.0 or GCC-7.3.0, but only because the mingwrt
versions associated with each of those earlier GCC versions were 5.1.0,
and 5.1.1 respectively; if I associate mingwrt-5.2.2, (or at least the
updated version of <stdio.h> from mingwrt-5.2.2), with each of those two
earlier GCC installations, I see the same issue propagate to all three!
The actual cause of the issue is that the changes to <stdio.h>, to
resolve https://osdn.net/projects/mingw/ticket/39224, cause g++ to emit
multiple publicly visible instances of vsnprintf(), each of which refers
to an extern implementation of __mingw_vsnprintf(), and conflicts with
its publicly visible vsprintf() alias, within the translation unit in
which __mingw_vsnprintf() itself is implemented.
The attached patch should correct this; please file a formal bug report,
at https://osdn.net/ticket/newticket.php?group_id=3917, against which I
may apply it.
--
Regards,
Keith.
Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F
_______________________________________________
MinGW-Users mailing list
[email protected]
This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated.
_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.osdn.me/mailman/listinfo/mingw-users
Also: mailto:[email protected]?subject=unsubscribe
vsnprintf-definition.patch
(text/x-patch, 2 KB)
# HG changeset patch # Parent 3427bddffcf749cf1bdfbbb894cd3db423084198 Avoid multiple vsnprintf() definitions * include/stdio.h [C++] (__mingw_stdio_redirect__): Defer to in-line definition applicable for C, when compiler suite is... [__GNUC__]: ...this. diff --git a/mingwrt/include/stdio.h b/mingwrt/include/stdio.h --- a/mingwrt/include/stdio.h +++ b/mingwrt/include/stdio.h @@ -377,30 +377,30 @@ extern unsigned int _mingw_output_format #if __USE_MINGW_ANSI_STDIO || defined _ISOC99_SOURCE /* User has expressed a preference for C99 conformance... */ # undef __mingw_stdio_redirect__ -# ifdef __cplusplus -/* For C++ we use inline implementations, to avoid interference +# if defined __GNUC__ +/* FIXME: Is there any GCC version prerequisite here? + * + * We prefer inline implementations for both C and C++, when we can be + * confident that the GNU specific __inline__ mechanism is supported. + */ +# define __mingw_stdio_redirect__ static __inline__ __cdecl __MINGW_NOTHROW + +# elif defined __cplusplus +/* For non-GNU C++ we use inline implementations, to avoid interference * with namespace qualification, which may result from using #defines. */ # define __mingw_stdio_redirect__ inline __cdecl __MINGW_NOTHROW -# elif defined __GNUC__ -/* FIXME: Is there any GCC version prerequisite here? - * - * We also prefer inline implementations for C, when we can be confident - * that the GNU specific __inline__ mechanism is supported. - */ -# define __mingw_stdio_redirect__ static __inline__ __cdecl __MINGW_NOTHROW - -# else /* Neither C++ nor __GNUC__ */ +# else /* Neither GCC, nor non-GNU C++ */ /* Can't use inlines; fall back on module local static stubs. */ # define __mingw_stdio_redirect__ static __cdecl __MINGW_NOTHROW -# endif /* Neither C++ nor __GNUC__ */ +# endif /* Neither GCC, nor non-GNU C++ */ #endif /* __USE_MINGW_ANSI_STDIO || defined _ISOC99_SOURCE */ #if __USE_MINGW_ANSI_STDIO /* The MinGW ISO-C conforming implementations of the printf() family * of functions are to be used, in place of non-conforming Microsoft
signature.asc
(application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) iQIcBAEBAgAGBQJdRH+GAAoJEMCtNsY0flo/7Y0P/R5ixK+QyaQDpC5tQxzgJHzh PtGBvPPz53Ts2+IWd42PCRibAArOK8IMi7Etof00UPpy4KJKfpzIJVl92PW6kunw 0dlN6c03n39K1FQiArOu7gvDdV1AWF7ffPcPdE4gr+yLgaUciypu4m61QE/7QyG8 2aLQgEsiCSSRAl26QoPY5lefUz3enG7ejrj2wKY6K8P2C6Y6WiI4ZZGp/lUZTJGD 9Zu32/y6Nx8FQyEwUA3+vhXvoM9xnm6WmVa5JTZNfQfshVfZHL6bOmrZgFD0ykgf mde8Y41VWRXy0E2zj274RGGaxR2ufhmsE0pqlw/kV44iAGy2NBAe1JYZGtazr/pI tBtBHa+OrL6i6YsowN5AkeyOwPWf6TaJ4Xw3gMsborrV79Ecol10qdMSM9Cn0t7P fDuOsJNfsC+2R5OG1DSpnsz/z73gBezQTsk/NoOS5tyE7OQFWyHlbdQ+CRAZTv0v 16XC3I8udCxvsIaVaQbXmxS3GKkASqLHCAVqV4QzxmdR85r4bXhbh/Vtxp4tffH3 h7F98m+sLfVqqpK/bPDiqMS6udmzbRNCux+s1qvjzhKKGJ1GMzO6WE9tnZ6Tvvqb DS8wXhxQssKmjDG35HyVq84lfEHRynVym6rCXtDd7b51pFqS+qA0LE10PneDcZFB SRLGdqa8L97uvJqYhhya =7twz -----END PGP SIGNATURE-----