This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fwd: [PATCH v1] setup: allow building with i686-w64-mingw32


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]