Opened 5 years ago

Closed 5 years ago

#15011 closed defect (fixed)

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

Reported by: guenter Owned by:
Priority: high Milestone:
Component: base Version: stable-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: yes


With flag '-std=c++11' Compiler gives error message: "...include/wx/wxcrtbase.h:697:62: error: '_strdup' was not declared in this scope " compiler version: mingw32-g++ (GCC) 4.7.2

Resolution: Respect defined 'STRICT_ANSI' with 'MINGW32'

diff --git a/include/wx/wxcrtbase.h b/include/wx/wxcrtbase.h
index 4061902..315e947 100644
--- a/include/wx/wxcrtbase.h
+++ b/include/wx/wxcrtbase.h
@@ -169,7 +169,7 @@ WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size );

strdup() but MinGW does provide it under MSVC-compatible name so test for it
before checking WX_STRICT_ANSI_GCC. */

#if (defined(VISUALC) && VISUALC >= 1400)
  • defined(MINGW32)

+ (defined(MINGW32) && !defined(STRICT_ANSI))

#define wxCRT_StrdupA _strdup

#elif !(defined(WXWINCE)

#define wxCRT_StrdupA strdup

Attachments (1)

wxcrtbase.h.patch download (630 bytes) - added by guenter 5 years ago.

Download all attachments as: .zip

Change History (2)

Changed 5 years ago by guenter


comment:1 Changed 5 years ago by VZ

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

(In [73627]) Fix compilation with MinGW -std=c++11 option.

With this option _strdup() is not available, so update the code defining
wxCRT_StrdupA() to check for WX_STRICT_ANSI_GCC.

Also try to simplify it a bit and make it more clear.

Closes #15011.

Note: See TracTickets for help on using tickets.