#15342 closed defect (fixed)

mingw32 compilation fails in wxcrtbase.h at 'wcsdup' with '-std=c++11'

Reported by: guenter Owned by:
Priority: normal Milestone:
Component: build Version: 2.9.5
Keywords: Cc:
Blocked By: Blocking:
Patch: yes

Description

Compilation error with mingw32 and c++11.

The known underscore-or-not-quiz .

git diff -w -- include/wx/wxcrtbase.h
diff --git a/include/wx/wxcrtbase.h b/include/wx/wxcrtbase.h
index c126980..be142c8 100644
--- a/include/wx/wxcrtbase.h
+++ b/include/wx/wxcrtbase.h
@@ -180,6 +180,10 @@ WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size );
 #if defined(__WINDOWS__) && \
         !(defined(__CYGWIN__)
defined(__WX_STRICT_ANSI_GCC__))
     #define wxCRT_StrdupW _wcsdup
+#elif defined(__MINGW32__)
+    #ifndef __WX_STRICT_ANSI_GCC__
+        #define wxCRT_StrdupW _wcsdup
+    #endif
 #elif defined(HAVE_WCSDUP)
     #define wxCRT_StrdupW wcsdup
 #endif

Attachments (2)

wxcrtbase.patch download (550 bytes) - added by guenter 16 months ago.
Patch for wxcrtbase.h
platform.h.patch download (470 bytes) - added by guenter 15 months ago.
patch for platform.h

Download all attachments as: .zip

Change History (10)

Changed 16 months ago by guenter

Patch for wxcrtbase.h

comment:1 follow-up: Changed 16 months ago by vadz

  • Status changed from new to infoneeded_new

Sorry, I don't understand this -- why doesn't the test just above take care of it? In your build, __WINDOWS__ should be defined, while neither __CYGWIN__ nor __WX_STRICT_ANSI_GCC__ shouldn't be (the latter because otherwise your patch wouldn't have any effect neither), so AFAICS the patch you propose mustn't change anything at all.

Or is the problem that HAVE_WCSDUP is defined by configure? But in this case, it should be fixed in configure, not here.

comment:2 in reply to: ↑ 1 Changed 16 months ago by guenter

Replying to vadz:

Sorry, I don't understand this -- why doesn't the test just above take care of it? In your build, __WINDOWS__ should be defined,

__WINDOWS__ is not defined, should it? Never needed to set this manually. I found only '__WXMSW__'  set manually as global define for wxWidgets projects.

comment:3 Changed 15 months ago by guenter

  • Status changed from infoneeded_new to new

comment:4 Changed 15 months ago by guenter

  • Patch set

comment:5 follow-up: Changed 15 months ago by vadz

  • Milestone 2.9.5 deleted
  • Status changed from new to infoneeded_new

So the real problem is that you define neither __WINDOWS__ nor _WIN32 (which is the standard symbol from which __WINDOWS__ is usually deduced) nor __WIN32__ but only __WXMSW__.

I guess we could define _WIN32 ourselves if __WXMSW__ is defined because, after all, this is the only platform wxMSW supports, but in the meanwhile your problem should be fixed by just defining one of the two symbols above.

I also still don't understand how can __WINDOWS__ be not defined if you're using configure because it does define __WINDOWS__, see the generated setup.h... Do you have any idea about what's going on here?

Changed 15 months ago by guenter

patch for platform.h

comment:6 in reply to: ↑ 5 Changed 15 months ago by guenter

  • Status changed from infoneeded_new to new

Replying to vadz:

So the real problem is that you define neither __WINDOWS__ nor _WIN32 (which is the standard symbol from which __WINDOWS__ is usually deduced) nor __WIN32__ but only __WXMSW__.

I guess we could define _WIN32 ourselves if __WXMSW__ is defined because, after all, this is the only platform wxMSW supports, but in the meanwhile your problem should be fixed by just defining one of the two symbols above.

I also still don't understand how can __WINDOWS__ be not defined if you're using configure because it does define __WINDOWS__, see the generated setup.h... Do you have any idea about what's going on here?

Nope, the generated setup.h doesn't care about __WINDOWS__ and considers {{{WXMSW}} only twice. Also the makefile.gcc and config.gcc do not mention them.

But I think I found the weak-doer: 'platform.h'. Please, some wxWidgets-on-Windows insider should have a look at this table "http://docs.wxwidgets.org/trunk/page_cppconst.html" and the trials in platform.h. Following that table the target OS should be given i.e. by __WIN32__, not? But in platform.h _WIN32 is treated as most important criteria, not?

My new patch proposal that works for me and should improve more cases:

diff --git a/include/wx/platform.h b/include/wx/platform.h
index 9eaffa8..5988d64 100644
--- a/include/wx/platform.h
+++ b/include/wx/platform.h
@@ -46,6 +46,10 @@
    first define Windows symbols if they're not defined on the command line: we
    can autodetect everything we need if _WIN32 is defined
  */
+#if defined(__WXMSW__)
+#    define __WINDOWS__
+#endif
+
 #if defined(__CYGWIN__) && defined(__WINDOWS__)
 #    ifndef __WXMSW__
 #        define __WXMSW__

comment:7 Changed 15 months ago by vadz

Thanks for looking into this, I agree that defining __WXMSW__ should be enough as it's currently supported only under Windows (doh), so I'll do it like this if it fixes your problems.

comment:8 Changed 15 months ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [74581]) Rearrange Windows checks in wx/platform.h to be more logical.

Use WINDOWS symbol as the primary symbol indicating Windows instead of
using all of _WIN32, WIN32 and WINDOWS.

Also automatically define WINDOWS if WXMSW is defined as this port
only can be used under Windows and doing it like this fixes compilation in the
case when the platform ends up being not defined at all, closes #15342.

Finally, don't assume Windows by default but give an error if we can't detect
the platform. This shouldn't happen in practice but seems a safer thing to do
if it ever does happen.

Note: See TracTickets for help on using tickets.