On 2012-06-12 04:37, Kai Tietz wrote:
> 2012/6/12 Yaakov (Cygwin/X):
>> Currently I get:
>>
>> /usr/i686-w64-mingw32/sys-root/mingw/lib/libmsvcrt.a(daqubs01139.o):(.text+0x0):
>> multiple definition of `_swprintf'
>> io_stream_file.o:/usr/i686-w64-mingw32/sys-root/mingw/include/wchar.h:547:
>> first defined here
>>
>> How about this change instead to both headers:
>>
>> --- crt/wchar.h (revision 5094)
>> +++ crt/wchar.h (working copy)
>> @@ -450,10 +450,10 @@
>>    int __cdecl __mingw_vsnwprintf (wchar_t * __restrict__ , size_t, const
>> wchar_t * __restrict__ , va_list);
>>
>>   #undef __mingw_ovr
>> -#ifdef __cplusplus
>> -#define __mingw_ovr  inline __cdecl
>> -#elif defined (__GNUC__)
>> +#if defined (__GNUC__)
>>   #define __mingw_ovr static __attribute__ ((__unused__)) __inline__ __cdecl
>> +#elif defined(__cplusplus)
>> +#define __mingw_ovr inline __cdecl
>>   #else
>>   #define __mingw_ovr static __cdecl
>>   #endif
>
> Hmm, that's looking wrong to me, too.  __GNUC__ gets defined also for
> c++, So issue might be more related to inline being not inlined.
> Could you provide me a small sample to reproduce this issue?

$ cat test.cc
#include <string>

int
test_printf(const std::string &str)
{
   return printf (str.c_str());
}

$ x86_64-w64-mingw32-g++ -c test.cc

$ x86_64-w64-mingw32-nm -C test.o
0000000000000000 b .bss
0000000000000000 d .data
0000000000000000 t .text
0000000000000000 t .text$printf
0000000000000000 T test_wprintf(std::string const&)
                  U std::string::c_str() const
                  U __mingw_vprintf
0000000000000000 T printf

$ x86_64-w64-mingw32-g++ -shared -Wl,--out-implib,libtest.dll.a -o 
libtest.dll test.o
Creating library file: libtest.dll.a

$ x86_64-w64-mingw32-nm -C libtest.dll.a  | grep  ' T '
0000000000000000 T printf
0000000000000000 T test_printf(std::string const&)

This code has no business exporting printf!  With my suggested change, 
however:

$ x86_64-w64-mingw32-nm -C test.o
0000000000000000 b .bss
0000000000000000 d .data
0000000000000000 t .text
000000000000003c T test_printf(std::string const&)
                  U std::string::c_str() const
                  U __mingw_vprintf
0000000000000000 t printf

$ x86_64-w64-mingw32-nm -C libtest.dll.a | grep ' T '
0000000000000000 T test_printf(std::string const&)


Yaakov
Cygwin/X

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to