Remove wxUSE_STL which is not really used any longer

wxString is always based on std::[w]string since 2c0c727f49 (Remove wx
own wxStringImpl implementation, 2022-11-16) and all containers use
standard containers by default too now -- and there is a separate
wxUSE_STD_CONTAINERS for this anyhow.

The only remaining use of wxUSE_STL was as the default value for
wxUSE_STD_STRING_CONV_IN_WXSTRING option, but it's not really needed
for this neither, and this option can just be set to 0 by default.

Also add wxUSE_CHAR_CONV_IN_WXSTRING which can now be set to 0 too to
disable all unwanted implicit conversions (even "safe" ones, to wide
strings, in addition to the unsafe ones to narrow strings that could be
already disabled with wxUSE_UNSAFE_WXSTRING_CONV) to allow people who
don't want to have any implicit conversions at all to do it.

Keep --enable-stl configure option for compatibility, but warn if it is
used to tell people that it is not needed any longer.
This commit is contained in:
Vadim Zeitlin 2023-04-15 15:42:10 +01:00
parent d65eed50fa
commit 35c35c235e
22 changed files with 315 additions and 248 deletions

View file

@ -94,10 +94,10 @@ jobs:
container: ubuntu:18.04
configure_flags: --disable-shared
use_xvfb: true
- name: Ubuntu 18.04 wxGTK 3 STL
- name: Ubuntu 18.04 wxGTK 3 compatible 3.0
runner: ubuntu-latest
container: ubuntu:18.04
configure_flags: --enable-stl --enable-compat30
configure_flags: --enable-compat30
use_xvfb: true
- name: Ubuntu 20.04 wxGTK 3 with clang
runner: ubuntu-20.04

View file

@ -82,10 +82,9 @@ jobs:
fail-fast: false
matrix:
include:
- name: wxMac ARM C++11 STL
- name: wxMac ARM with ASAN
runner: self-hosted
arch: arm64
configure_flags: --with-cxx=11 --enable-stl
use_asan: true
- name: wxMac Intel C++17
runner: self-hosted

View file

@ -76,7 +76,6 @@ jobs:
- configuration: 'DLL Release'
platform: 'x64'
vsversion: 2019
use_stl: true
steps:
- name: Checkout
@ -87,12 +86,10 @@ jobs:
- name: Configure build options
working-directory: include/wx/msw
run: |
$use_stl = "${{ matrix.use_stl }}" ? 1 : 0
$use_utf8 = "${{ matrix.use_utf8 }}" ? 1 : 0
if ( $use_stl -or $use_utf8 ) {
if ( $use_utf8 ) {
$txt = Get-Content setup.h
Write-Output $txt |
%{$_ -replace "define wxUSE_STL 0", "define wxUSE_STL $use_stl"} |
%{$_ -replace "define wxUSE_UNICODE_UTF8 0", "define wxUSE_UNICODE_UTF8 $use_utf8"} |
Set-Content setup.h
}

View file

@ -75,7 +75,7 @@ jobs:
matrix:
include:
- name: wxMSW 64 bits
configure_flags: --enable-stl --disable-compat32
configure_flags: --disable-compat32
- name: wxMSW 32 bits
triplet: i686-w64-mingw32
env:

View file

@ -33,7 +33,6 @@ environment:
- TOOLSET: msbuild
CONFIGURATION: DLL Release
ARCH: x64
wxUSE_STL: 1
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
- TOOLSET: msbuild
CONFIGURATION: Debug
@ -44,7 +43,6 @@ environment:
VS: '14.0'
BUILD: debug
ARCH: amd64
wxUSE_STL: 1
wxUSE_WEBVIEW_EDGE: 1
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
- TOOLSET: cmake
@ -72,13 +70,11 @@ init:
before_build:
- ps: |
$env:PATH = $env:PATH -replace "C:\\Program Files\\Git\\usr\\bin",""
if (-not (Test-Path env:wxUSE_STL)) { $env:wxUSE_STL = '0' }
if (-not (Test-Path env:wxUSE_UNICODE_UTF8)) { $env:wxUSE_UNICODE_UTF8 = '0' }
if (-not (Test-Path env:wxUSE_WEBVIEW_EDGE)) { $env:wxUSE_WEBVIEW_EDGE = '0' }
if (($env:TOOLSET -ne "msys2") -and ($env:TOOLSET -ne "cygwin")) {
$txt = gc include\wx\msw\setup.h
Write-Output $txt |
%{$_ -replace "define wxUSE_STL 0", "define wxUSE_STL $env:wxUSE_STL"} |
%{$_ -replace "define wxUSE_UNICODE_UTF8 0", "define wxUSE_UNICODE_UTF8 $env:wxUSE_UNICODE_UTF8"} |
%{$_ -replace "define wxUSE_WEBVIEW_EDGE 0", "define wxUSE_WEBVIEW_EDGE $env:wxUSE_WEBVIEW_EDGE"} |
sc include\wx\msw\setup.h

View file

@ -82,8 +82,6 @@ wx_option(wxUSE_NO_RTTI "disable RTTI support" OFF)
# STL options
wx_option(wxUSE_STD_IOSTREAM "use standard C++ streams" ON)
wx_option(wxUSE_STL "use standard C++ classes for everything" OFF)
set(wxTHIRD_PARTY_LIBRARIES ${wxTHIRD_PARTY_LIBRARIES} wxUSE_STL "use C++ STL classes")
wx_option(wxUSE_STD_CONTAINERS "use standard C++ container classes" ON)
wx_option(wxUSE_UNICODE_UTF8 "use UTF-8 representation for strings" OFF)
@ -92,6 +90,8 @@ wx_dependent_option(wxUSE_UTF8_LOCALE_ONLY "only support UTF-8 locales in UTF-8
if(NOT WIN32)
wx_option(wxUSE_VISIBILITY "use of ELF symbols visibility")
endif()
wx_option(wxUSE_CHAR_CONV_IN_WXSTRING "provide implicit conversions to const wchar_t* and const char* in wxString" ON)
wx_option(wxUSE_STD_STRING_CONV_IN_WXSTRING "provide implicit conversions to std::wstring and std::string in wxString" OFF)
wx_option(wxUSE_UNSAFE_WXSTRING_CONV "provide unsafe implicit conversions in wxString to const char* or std::string")
wx_option(wxUSE_REPRODUCIBLE_BUILD "enable reproducable build" OFF)

View file

@ -114,8 +114,6 @@
#cmakedefine01 wxDIALOG_UNIT_COMPATIBILITY
#cmakedefine01 wxUSE_UNSAFE_WXSTRING_CONV
#cmakedefine01 wxUSE_REPRODUCIBLE_BUILD
@ -154,12 +152,16 @@
#cmakedefine01 wxUSE_PRINTF_POS_PARAMS
#cmakedefine01 wxUSE_STL
#cmakedefine01 wxUSE_STD_CONTAINERS
#cmakedefine01 wxUSE_STD_IOSTREAM
#define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL
#cmakedefine01 wxUSE_UNSAFE_WXSTRING_CONV
#cmakedefine01 wxUSE_CHAR_CONV_IN_WXSTRING
#cmakedefine01 wxUSE_STD_STRING_CONV_IN_WXSTRING
#cmakedefine01 wxUSE_LONGLONG

43
configure vendored
View file

@ -1122,6 +1122,7 @@ with_cxx
enable_stl
enable_std_containers
enable_std_iostreams
enable_char_conv_in_wxstring
enable_std_string_conv_in_wxstring
enable_unsafe_conv_in_wxstring
enable_utf8
@ -2085,9 +2086,10 @@ Optional Features:
--enable-debug_gdb create code with extra GDB debugging information
--disable-shared create static library instead of shared
--enable-cxx11 obsolete option doing nothing
--enable-stl use standard C++ classes for everything
--enable-stl obsolete option doing nothing
--disable-std_containers disable use of standard C++ container classes
--disable-std_iostreams disable use of standard C++ stream classes
--disable-char_conv_in_wxstring disable implicit conversion to const wchar_t/char* in wxString
--enable-std_string_conv_in_wxstring provide implicit conversion to std::string in wxString
--disable-unsafe_conv_in_wxstring disable unsafe implicit conversions in wxString
--enable-utf8 use UTF-8 representation for strings
@ -5635,6 +5637,35 @@ fi
eval "$wx_cv_use_std_iostreams"
enablestring=disable
defaultval=
if test -z "$defaultval"; then
if test x"$enablestring" = xdisable; then
defaultval=yes
else
defaultval=no
fi
fi
# Check whether --enable-char_conv_in_wxstring was given.
if test "${enable_char_conv_in_wxstring+set}" = set; then :
enableval=$enable_char_conv_in_wxstring;
if test "$enableval" = yes; then
wx_cv_use_char_conv_in_wxstring='wxUSE_CHAR_CONV_IN_WXSTRING=yes'
else
wx_cv_use_char_conv_in_wxstring='wxUSE_CHAR_CONV_IN_WXSTRING=no'
fi
else
wx_cv_use_char_conv_in_wxstring='wxUSE_CHAR_CONV_IN_WXSTRING=${'DEFAULT_wxUSE_CHAR_CONV_IN_WXSTRING":-$defaultval}"
fi
eval "$wx_cv_use_char_conv_in_wxstring"
enablestring=
defaultval=
if test -z "$defaultval"; then
@ -36116,8 +36147,8 @@ fi
if test "$wxUSE_STL" = "yes"; then
$as_echo "#define wxUSE_STL 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --enable-stl option is not needed any more and can be simply removed" >&5
$as_echo "$as_me: WARNING: --enable-stl option is not needed any more and can be simply removed" >&2;}
fi
if test "$wxUSE_EXTENDED_RTTI" = "yes"; then
@ -37433,6 +37464,11 @@ if test "$wxUSE_STD_IOSTREAM" = "yes"; then
fi
if test "$wxUSE_CHAR_CONV_IN_WXSTRING" = "yes"; then
$as_echo "#define wxUSE_CHAR_CONV_IN_WXSTRING 1" >>confdefs.h
fi
if test "$wxUSE_STD_STRING_CONV_IN_WXSTRING" = "yes"; then
$as_echo "#define wxUSE_STD_STRING_CONV_IN_WXSTRING 1" >>confdefs.h
@ -45225,7 +45261,6 @@ echo " wxWidgets 3.0 ${WXWIN_COMPATIB
echo " wxWidgets 3.2 ${WXWIN_COMPATIBILITY_3_2:-yes}"
echo " Which libraries should wxWidgets use?"
echo " STL ${wxUSE_STL}"
echo " jpeg ${wxUSE_LIBJPEG-none}"
echo " png ${wxUSE_LIBPNG-none}"
echo " regex ${wxUSE_REGEX}"

View file

@ -639,9 +639,10 @@ dnl ---------------------------------------------------------------------------
WX_ARG_DISABLE(shared, [ --disable-shared create static library instead of shared], wxUSE_SHARED)
AC_ARG_ENABLE(cxx11, [ --enable-cxx11 obsolete option doing nothing])
AC_ARG_WITH(cxx, [ --with-cxx=11|14|17|20 use the given C++ dialect], [wxWITH_CXX="$withval"])
WX_ARG_ENABLE(stl, [ --enable-stl use standard C++ classes for everything], wxUSE_STL)
WX_ARG_ENABLE(stl, [ --enable-stl obsolete option doing nothing], wxUSE_STL)
WX_ARG_DISABLE(std_containers,[ --disable-std_containers disable use of standard C++ container classes], wxUSE_STD_CONTAINERS)
WX_ARG_DISABLE(std_iostreams,[ --disable-std_iostreams disable use of standard C++ stream classes], wxUSE_STD_IOSTREAM)
WX_ARG_DISABLE(char_conv_in_wxstring, [ --disable-char_conv_in_wxstring disable implicit conversion to const wchar_t/char* in wxString], wxUSE_CHAR_CONV_IN_WXSTRING)
WX_ARG_ENABLE(std_string_conv_in_wxstring, [ --enable-std_string_conv_in_wxstring provide implicit conversion to std::string in wxString], wxUSE_STD_STRING_CONV_IN_WXSTRING)
WX_ARG_DISABLE(unsafe_conv_in_wxstring, [ --disable-unsafe_conv_in_wxstring disable unsafe implicit conversions in wxString], wxUSE_UNSAFE_WXSTRING_CONV)
WX_ARG_ENABLE_PARAM(utf8, [ --enable-utf8 use UTF-8 representation for strings], wxUSE_UNICODE_UTF8)
@ -5088,7 +5089,7 @@ dnl Register non-GUI class options for makefiles and setup.h
dnl ---------------------------------------------------------------------------
if test "$wxUSE_STL" = "yes"; then
AC_DEFINE(wxUSE_STL)
AC_MSG_WARN([--enable-stl option is not needed any more and can be simply removed])
fi
if test "$wxUSE_EXTENDED_RTTI" = "yes"; then
@ -5390,6 +5391,10 @@ if test "$wxUSE_STD_IOSTREAM" = "yes"; then
AC_DEFINE(wxUSE_STD_IOSTREAM)
fi
if test "$wxUSE_CHAR_CONV_IN_WXSTRING" = "yes"; then
AC_DEFINE(wxUSE_CHAR_CONV_IN_WXSTRING)
fi
if test "$wxUSE_STD_STRING_CONV_IN_WXSTRING" = "yes"; then
AC_DEFINE(wxUSE_STD_STRING_CONV_IN_WXSTRING)
fi
@ -8178,7 +8183,6 @@ echo " wxWidgets 3.0 ${WXWIN_COMPATIB
echo " wxWidgets 3.2 ${WXWIN_COMPATIBILITY_3_2:-yes}"
echo " Which libraries should wxWidgets use?"
echo " STL ${wxUSE_STL}"
echo " jpeg ${wxUSE_LIBJPEG-none}"
echo " png ${wxUSE_LIBPNG-none}"
echo " regex ${wxUSE_REGEX}"

View file

@ -92,6 +92,11 @@ Changes in behaviour which may result in build errors
the existing code. Alternatively, explicitly set wxUSE_STD_CONTAINERS=0 when
compiling the library to preserve full compatibility with the old versions.
- wxUSE_STL option doesn't exist any longer, standard library is always used.
However previously setting wxUSE_STL=1 enabled implicit conversion from
wxString to std::[w]string which are not enabled by default now, please set
wxUSE_STD_STRING_CONV_IN_WXSTRING=1 explicitly if you need them.
- wxMotif and wxGTK1 ports have been removed, please use wxWidgets 3.2 if you
still need them.

View file

@ -339,12 +339,11 @@ more details.
with old wxWidgets versions. Changing it is not recommended.}
@itemdef{wxUSE_UNSAFE_WXSTRING_CONV,
this option determines if unsafe implicit conversions of wxString to
@c char* or @c std::string (depending on whether @c wxUSE_STL is 0 or
1) are defined. It is set to 1 by default for compatibility reasons,
however it is recommended to set it to 0 for the new projects. See
also @c wxNO_UNSAFE_WXSTRING_CONV below for an alternative way of
disabling these unsafe conversions not requiring rebuilding the
library.}
@c char* or @c std::string (depending on whether
@c wxUSE_STD_STRING_CONV_IN_WXSTRING is 0 or 1) are defined.
It is set to 1 by default for compatibility reasons, but you may set
@c wxNO_UNSAFE_WXSTRING_CONV described below to disable these unsafe
unsafe conversions without rebuilding the library.}
@endDefList
@section page_cppconst_miscellaneous Miscellaneous

View file

@ -55,18 +55,6 @@
// Recommended setting: 0
#define wxDIALOG_UNIT_COMPATIBILITY 0
// Provide unsafe implicit conversions in wxString to "const char*" or
// "std::string" (depending on wxUSE_STD_STRING_CONV_IN_WXSTRING value).
//
// Default is 1 but only for compatibility reasons, it is recommended to set
// this to 0 because converting wxString to a narrow (non-Unicode) string may
// fail unless a locale using UTF-8 encoding is used, which is never the case
// under MSW, for example, hence such conversions can result in silent data
// loss.
//
// Recommended setting: 0
#define wxUSE_UNSAFE_WXSTRING_CONV 1
// If set to 1, enables "reproducible builds", i.e. build output should be
// exactly the same if the same build is redone again. As using __DATE__ and
// __TIME__ macros clearly makes the build irreproducible, setting this option
@ -272,15 +260,6 @@
// Interoperability with the standard library.
// ----------------------------------------------------------------------------
// Set wxUSE_STL to 1 to enable maximal interoperability with the standard
// library, even at the cost of backwards compatibility.
//
// Default is 0
//
// Recommended setting: 1 for new code bases and if compatibility with the
// official build of the library is not important, 0 otherwise.
#define wxUSE_STL 0
// Use standard C++ containers to implement all wx container classes.
//
// Default is 1.
@ -299,24 +278,51 @@
//
// Recommended setting: 1.
#define wxUSE_STD_IOSTREAM 1
// Make wxString as much interchangeable with std::[w]string as possible, in
// particular allow implicit conversion of wxString to either of these classes.
// This comes at a price (or a benefit, depending on your point of view) of not
// allowing implicit conversion to "const char *" and "const wchar_t *".
// ----------------------------------------------------------------------------
// wxString-related options
// ----------------------------------------------------------------------------
// Provide unsafe implicit conversions in wxString to "const char*" or
// "std::string" (depending on wxUSE_STD_STRING_CONV_IN_WXSTRING value).
//
// Because a lot of existing code relies on these conversions, this option is
// disabled by default but can be enabled for your build if you don't care
// about compatibility.
// Default is 1 for compatibility reasons, it is recommended to set
// this to 0 because converting wxString to a narrow (non-Unicode) string may
// fail unless a locale using UTF-8 encoding is used, which is never the case
// under MSW, for example, hence such conversions can result in silent data
// loss.
//
// Recommended setting: 1 to remain compatible with the official builds of
// wxWidgets, but define wxNO_UNSAFE_WXSTRING_CONV when compiling the
// application code to effectively disallow using these conversions.
#define wxUSE_UNSAFE_WXSTRING_CONV 1
// Define implicit conversions of wxString to "const wchar_t*" and "const
// char*" if wxUSE_UNSAFE_WXSTRING_CONV is also enabled.
//
// Default is 1.
//
// Recommended setting: 1 to remain compatible with the official builds of
// wxWidgets but may be set to 0 to prevent any accidental conversions from
// happening.
#define wxUSE_CHAR_CONV_IN_WXSTRING 1
// Define implicit conversions of wxString to std::wstring and std::string if
// wxUSE_UNSAFE_WXSTRING_CONV is also enabled.
//
// Note that wxString can always be constructed from std::[w]string, whether
// this option is turned on or off, it only enables implicit conversion in the
// other direction.
//
// Default is 0 if wxUSE_STL has its default value or 1 if it is enabled.
// If this setting is changed to 1, wxUSE_CHAR_CONV_IN_WXSTRING must be set to
// 0 as setting both of them to 1 will result in ambiguities due to having too
// many implicit conversions defined.
//
// Recommended setting: 0 to remain compatible with the official builds of
// wxWidgets.
#define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL
// Default is 0.
//
// Recommended setting: 0, use wxString::ToStdWstring() and ToStdString() or,
// preferably, utf8_string() explicitly instead.
#define wxUSE_STD_STRING_CONV_IN_WXSTRING 0
// ----------------------------------------------------------------------------
// non GUI features selection

View file

@ -56,18 +56,6 @@
// Recommended setting: 0
#define wxDIALOG_UNIT_COMPATIBILITY 0
// Provide unsafe implicit conversions in wxString to "const char*" or
// "std::string" (depending on wxUSE_STD_STRING_CONV_IN_WXSTRING value).
//
// Default is 1 but only for compatibility reasons, it is recommended to set
// this to 0 because converting wxString to a narrow (non-Unicode) string may
// fail unless a locale using UTF-8 encoding is used, which is never the case
// under MSW, for example, hence such conversions can result in silent data
// loss.
//
// Recommended setting: 0
#define wxUSE_UNSAFE_WXSTRING_CONV 1
// If set to 1, enables "reproducible builds", i.e. build output should be
// exactly the same if the same build is redone again. As using __DATE__ and
// __TIME__ macros clearly makes the build irreproducible, setting this option
@ -273,15 +261,6 @@
// Interoperability with the standard library.
// ----------------------------------------------------------------------------
// Set wxUSE_STL to 1 to enable maximal interoperability with the standard
// library, even at the cost of backwards compatibility.
//
// Default is 0
//
// Recommended setting: 1 for new code bases and if compatibility with the
// official build of the library is not important, 0 otherwise.
#define wxUSE_STL 0
// Use standard C++ containers to implement all wx container classes.
//
// Default is 1.
@ -300,24 +279,51 @@
//
// Recommended setting: 1.
#define wxUSE_STD_IOSTREAM 1
// Make wxString as much interchangeable with std::[w]string as possible, in
// particular allow implicit conversion of wxString to either of these classes.
// This comes at a price (or a benefit, depending on your point of view) of not
// allowing implicit conversion to "const char *" and "const wchar_t *".
// ----------------------------------------------------------------------------
// wxString-related options
// ----------------------------------------------------------------------------
// Provide unsafe implicit conversions in wxString to "const char*" or
// "std::string" (depending on wxUSE_STD_STRING_CONV_IN_WXSTRING value).
//
// Because a lot of existing code relies on these conversions, this option is
// disabled by default but can be enabled for your build if you don't care
// about compatibility.
// Default is 1 for compatibility reasons, it is recommended to set
// this to 0 because converting wxString to a narrow (non-Unicode) string may
// fail unless a locale using UTF-8 encoding is used, which is never the case
// under MSW, for example, hence such conversions can result in silent data
// loss.
//
// Recommended setting: 1 to remain compatible with the official builds of
// wxWidgets, but define wxNO_UNSAFE_WXSTRING_CONV when compiling the
// application code to effectively disallow using these conversions.
#define wxUSE_UNSAFE_WXSTRING_CONV 1
// Define implicit conversions of wxString to "const wchar_t*" and "const
// char*" if wxUSE_UNSAFE_WXSTRING_CONV is also enabled.
//
// Default is 1.
//
// Recommended setting: 1 to remain compatible with the official builds of
// wxWidgets but may be set to 0 to prevent any accidental conversions from
// happening.
#define wxUSE_CHAR_CONV_IN_WXSTRING 1
// Define implicit conversions of wxString to std::wstring and std::string if
// wxUSE_UNSAFE_WXSTRING_CONV is also enabled.
//
// Note that wxString can always be constructed from std::[w]string, whether
// this option is turned on or off, it only enables implicit conversion in the
// other direction.
//
// Default is 0 if wxUSE_STL has its default value or 1 if it is enabled.
// If this setting is changed to 1, wxUSE_CHAR_CONV_IN_WXSTRING must be set to
// 0 as setting both of them to 1 will result in ambiguities due to having too
// many implicit conversions defined.
//
// Recommended setting: 0 to remain compatible with the official builds of
// wxWidgets.
#define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL
// Default is 0.
//
// Recommended setting: 0, use wxString::ToStdWstring() and ToStdString() or,
// preferably, utf8_string() explicitly instead.
#define wxUSE_STD_STRING_CONV_IN_WXSTRING 0
// ----------------------------------------------------------------------------
// non GUI features selection

View file

@ -56,18 +56,6 @@
// Recommended setting: 0
#define wxDIALOG_UNIT_COMPATIBILITY 0
// Provide unsafe implicit conversions in wxString to "const char*" or
// "std::string" (depending on wxUSE_STD_STRING_CONV_IN_WXSTRING value).
//
// Default is 1 but only for compatibility reasons, it is recommended to set
// this to 0 because converting wxString to a narrow (non-Unicode) string may
// fail unless a locale using UTF-8 encoding is used, which is never the case
// under MSW, for example, hence such conversions can result in silent data
// loss.
//
// Recommended setting: 0
#define wxUSE_UNSAFE_WXSTRING_CONV 1
// If set to 1, enables "reproducible builds", i.e. build output should be
// exactly the same if the same build is redone again. As using __DATE__ and
// __TIME__ macros clearly makes the build irreproducible, setting this option
@ -273,15 +261,6 @@
// Interoperability with the standard library.
// ----------------------------------------------------------------------------
// Set wxUSE_STL to 1 to enable maximal interoperability with the standard
// library, even at the cost of backwards compatibility.
//
// Default is 0
//
// Recommended setting: 1 for new code bases and if compatibility with the
// official build of the library is not important, 0 otherwise.
#define wxUSE_STL 0
// Use standard C++ containers to implement all wx container classes.
//
// Default is 1.
@ -300,24 +279,51 @@
//
// Recommended setting: 1.
#define wxUSE_STD_IOSTREAM 1
// Make wxString as much interchangeable with std::[w]string as possible, in
// particular allow implicit conversion of wxString to either of these classes.
// This comes at a price (or a benefit, depending on your point of view) of not
// allowing implicit conversion to "const char *" and "const wchar_t *".
// ----------------------------------------------------------------------------
// wxString-related options
// ----------------------------------------------------------------------------
// Provide unsafe implicit conversions in wxString to "const char*" or
// "std::string" (depending on wxUSE_STD_STRING_CONV_IN_WXSTRING value).
//
// Because a lot of existing code relies on these conversions, this option is
// disabled by default but can be enabled for your build if you don't care
// about compatibility.
// Default is 1 for compatibility reasons, it is recommended to set
// this to 0 because converting wxString to a narrow (non-Unicode) string may
// fail unless a locale using UTF-8 encoding is used, which is never the case
// under MSW, for example, hence such conversions can result in silent data
// loss.
//
// Recommended setting: 1 to remain compatible with the official builds of
// wxWidgets, but define wxNO_UNSAFE_WXSTRING_CONV when compiling the
// application code to effectively disallow using these conversions.
#define wxUSE_UNSAFE_WXSTRING_CONV 1
// Define implicit conversions of wxString to "const wchar_t*" and "const
// char*" if wxUSE_UNSAFE_WXSTRING_CONV is also enabled.
//
// Default is 1.
//
// Recommended setting: 1 to remain compatible with the official builds of
// wxWidgets but may be set to 0 to prevent any accidental conversions from
// happening.
#define wxUSE_CHAR_CONV_IN_WXSTRING 1
// Define implicit conversions of wxString to std::wstring and std::string if
// wxUSE_UNSAFE_WXSTRING_CONV is also enabled.
//
// Note that wxString can always be constructed from std::[w]string, whether
// this option is turned on or off, it only enables implicit conversion in the
// other direction.
//
// Default is 0 if wxUSE_STL has its default value or 1 if it is enabled.
// If this setting is changed to 1, wxUSE_CHAR_CONV_IN_WXSTRING must be set to
// 0 as setting both of them to 1 will result in ambiguities due to having too
// many implicit conversions defined.
//
// Recommended setting: 0 to remain compatible with the official builds of
// wxWidgets.
#define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL
// Default is 0.
//
// Recommended setting: 0, use wxString::ToStdWstring() and ToStdString() or,
// preferably, utf8_string() explicitly instead.
#define wxUSE_STD_STRING_CONV_IN_WXSTRING 0
// ----------------------------------------------------------------------------
// non GUI features selection

View file

@ -62,18 +62,6 @@
// Recommended setting: 0
#define wxDIALOG_UNIT_COMPATIBILITY 0
// Provide unsafe implicit conversions in wxString to "const char*" or
// "std::string" (depending on wxUSE_STD_STRING_CONV_IN_WXSTRING value).
//
// Default is 1 but only for compatibility reasons, it is recommended to set
// this to 0 because converting wxString to a narrow (non-Unicode) string may
// fail unless a locale using UTF-8 encoding is used, which is never the case
// under MSW, for example, hence such conversions can result in silent data
// loss.
//
// Recommended setting: 0
#define wxUSE_UNSAFE_WXSTRING_CONV 1
// If set to 1, enables "reproducible builds", i.e. build output should be
// exactly the same if the same build is redone again. As using __DATE__ and
// __TIME__ macros clearly makes the build irreproducible, setting this option
@ -279,15 +267,6 @@
// Interoperability with the standard library.
// ----------------------------------------------------------------------------
// Set wxUSE_STL to 1 to enable maximal interoperability with the standard
// library, even at the cost of backwards compatibility.
//
// Default is 0
//
// Recommended setting: 1 for new code bases and if compatibility with the
// official build of the library is not important, 0 otherwise.
#define wxUSE_STL 0
// Use standard C++ containers to implement all wx container classes.
//
// Default is 1.
@ -306,24 +285,51 @@
//
// Recommended setting: 1.
#define wxUSE_STD_IOSTREAM 1
// Make wxString as much interchangeable with std::[w]string as possible, in
// particular allow implicit conversion of wxString to either of these classes.
// This comes at a price (or a benefit, depending on your point of view) of not
// allowing implicit conversion to "const char *" and "const wchar_t *".
// ----------------------------------------------------------------------------
// wxString-related options
// ----------------------------------------------------------------------------
// Provide unsafe implicit conversions in wxString to "const char*" or
// "std::string" (depending on wxUSE_STD_STRING_CONV_IN_WXSTRING value).
//
// Because a lot of existing code relies on these conversions, this option is
// disabled by default but can be enabled for your build if you don't care
// about compatibility.
// Default is 1 for compatibility reasons, it is recommended to set
// this to 0 because converting wxString to a narrow (non-Unicode) string may
// fail unless a locale using UTF-8 encoding is used, which is never the case
// under MSW, for example, hence such conversions can result in silent data
// loss.
//
// Recommended setting: 1 to remain compatible with the official builds of
// wxWidgets, but define wxNO_UNSAFE_WXSTRING_CONV when compiling the
// application code to effectively disallow using these conversions.
#define wxUSE_UNSAFE_WXSTRING_CONV 1
// Define implicit conversions of wxString to "const wchar_t*" and "const
// char*" if wxUSE_UNSAFE_WXSTRING_CONV is also enabled.
//
// Default is 1.
//
// Recommended setting: 1 to remain compatible with the official builds of
// wxWidgets but may be set to 0 to prevent any accidental conversions from
// happening.
#define wxUSE_CHAR_CONV_IN_WXSTRING 1
// Define implicit conversions of wxString to std::wstring and std::string if
// wxUSE_UNSAFE_WXSTRING_CONV is also enabled.
//
// Note that wxString can always be constructed from std::[w]string, whether
// this option is turned on or off, it only enables implicit conversion in the
// other direction.
//
// Default is 0 if wxUSE_STL has its default value or 1 if it is enabled.
// If this setting is changed to 1, wxUSE_CHAR_CONV_IN_WXSTRING must be set to
// 0 as setting both of them to 1 will result in ambiguities due to having too
// many implicit conversions defined.
//
// Recommended setting: 0 to remain compatible with the official builds of
// wxWidgets.
#define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL
// Default is 0.
//
// Recommended setting: 0, use wxString::ToStdWstring() and ToStdString() or,
// preferably, utf8_string() explicitly instead.
#define wxUSE_STD_STRING_CONV_IN_WXSTRING 0
// ----------------------------------------------------------------------------
// non GUI features selection

View file

@ -52,18 +52,6 @@
// Recommended setting: 0
#define wxDIALOG_UNIT_COMPATIBILITY 0
// Provide unsafe implicit conversions in wxString to "const char*" or
// "std::string" (depending on wxUSE_STD_STRING_CONV_IN_WXSTRING value).
//
// Default is 1 but only for compatibility reasons, it is recommended to set
// this to 0 because converting wxString to a narrow (non-Unicode) string may
// fail unless a locale using UTF-8 encoding is used, which is never the case
// under MSW, for example, hence such conversions can result in silent data
// loss.
//
// Recommended setting: 0
#define wxUSE_UNSAFE_WXSTRING_CONV 1
// If set to 1, enables "reproducible builds", i.e. build output should be
// exactly the same if the same build is redone again. As using __DATE__ and
// __TIME__ macros clearly makes the build irreproducible, setting this option
@ -269,15 +257,6 @@
// Interoperability with the standard library.
// ----------------------------------------------------------------------------
// Set wxUSE_STL to 1 to enable maximal interoperability with the standard
// library, even at the cost of backwards compatibility.
//
// Default is 0
//
// Recommended setting: 1 for new code bases and if compatibility with the
// official build of the library is not important, 0 otherwise.
#define wxUSE_STL 0
// Use standard C++ containers to implement all wx container classes.
//
// Default is 1.
@ -296,24 +275,51 @@
//
// Recommended setting: 1.
#define wxUSE_STD_IOSTREAM 1
// Make wxString as much interchangeable with std::[w]string as possible, in
// particular allow implicit conversion of wxString to either of these classes.
// This comes at a price (or a benefit, depending on your point of view) of not
// allowing implicit conversion to "const char *" and "const wchar_t *".
// ----------------------------------------------------------------------------
// wxString-related options
// ----------------------------------------------------------------------------
// Provide unsafe implicit conversions in wxString to "const char*" or
// "std::string" (depending on wxUSE_STD_STRING_CONV_IN_WXSTRING value).
//
// Because a lot of existing code relies on these conversions, this option is
// disabled by default but can be enabled for your build if you don't care
// about compatibility.
// Default is 1 for compatibility reasons, it is recommended to set
// this to 0 because converting wxString to a narrow (non-Unicode) string may
// fail unless a locale using UTF-8 encoding is used, which is never the case
// under MSW, for example, hence such conversions can result in silent data
// loss.
//
// Recommended setting: 1 to remain compatible with the official builds of
// wxWidgets, but define wxNO_UNSAFE_WXSTRING_CONV when compiling the
// application code to effectively disallow using these conversions.
#define wxUSE_UNSAFE_WXSTRING_CONV 1
// Define implicit conversions of wxString to "const wchar_t*" and "const
// char*" if wxUSE_UNSAFE_WXSTRING_CONV is also enabled.
//
// Default is 1.
//
// Recommended setting: 1 to remain compatible with the official builds of
// wxWidgets but may be set to 0 to prevent any accidental conversions from
// happening.
#define wxUSE_CHAR_CONV_IN_WXSTRING 1
// Define implicit conversions of wxString to std::wstring and std::string if
// wxUSE_UNSAFE_WXSTRING_CONV is also enabled.
//
// Note that wxString can always be constructed from std::[w]string, whether
// this option is turned on or off, it only enables implicit conversion in the
// other direction.
//
// Default is 0 if wxUSE_STL has its default value or 1 if it is enabled.
// If this setting is changed to 1, wxUSE_CHAR_CONV_IN_WXSTRING must be set to
// 0 as setting both of them to 1 will result in ambiguities due to having too
// many implicit conversions defined.
//
// Recommended setting: 0 to remain compatible with the official builds of
// wxWidgets.
#define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL
// Default is 0.
//
// Recommended setting: 0, use wxString::ToStdWstring() and ToStdString() or,
// preferably, utf8_string() explicitly instead.
#define wxUSE_STD_STRING_CONV_IN_WXSTRING 0
// ----------------------------------------------------------------------------
// non GUI features selection

View file

@ -1536,13 +1536,7 @@ public:
// implicit conversion to wxCStrData
operator wxCStrData() const { return c_str(); }
// the first two operators conflict with operators for conversion to
// std::string and they must be disabled if those conversions are enabled;
// the next one only makes sense if conversions to char* are also defined
// and not defining it in STL build also helps us to get more clear error
// messages for the code which relies on implicit conversion to char* in
// STL build
#if !wxUSE_STD_STRING_CONV_IN_WXSTRING
#if wxUSE_CHAR_CONV_IN_WXSTRING
operator const wchar_t*() const { return c_str(); }
#if wxUSE_UNSAFE_WXSTRING_CONV && !defined(wxNO_UNSAFE_WXSTRING_CONV)
@ -1553,7 +1547,7 @@ public:
operator const void*() const { return c_str(); }
#endif // wxUSE_UNSAFE_WXSTRING_CONV && !defined(wxNO_UNSAFE_WXSTRING_CONV)
#endif // !wxUSE_STD_STRING_CONV_IN_WXSTRING
#endif // wxUSE_CHAR_CONV_IN_WXSTRING
// identical to c_str(), for MFC compatibility
const wxCStrData GetData() const { return c_str(); }

View file

@ -55,18 +55,6 @@
// Recommended setting: 0
#define wxDIALOG_UNIT_COMPATIBILITY 0
// Provide unsafe implicit conversions in wxString to "const char*" or
// "std::string" (depending on wxUSE_STD_STRING_CONV_IN_WXSTRING value).
//
// Default is 1 but only for compatibility reasons, it is recommended to set
// this to 0 because converting wxString to a narrow (non-Unicode) string may
// fail unless a locale using UTF-8 encoding is used, which is never the case
// under MSW, for example, hence such conversions can result in silent data
// loss.
//
// Recommended setting: 0
#define wxUSE_UNSAFE_WXSTRING_CONV 1
// If set to 1, enables "reproducible builds", i.e. build output should be
// exactly the same if the same build is redone again. As using __DATE__ and
// __TIME__ macros clearly makes the build irreproducible, setting this option
@ -272,15 +260,6 @@
// Interoperability with the standard library.
// ----------------------------------------------------------------------------
// Set wxUSE_STL to 1 to enable maximal interoperability with the standard
// library, even at the cost of backwards compatibility.
//
// Default is 0
//
// Recommended setting: 1 for new code bases and if compatibility with the
// official build of the library is not important, 0 otherwise.
#define wxUSE_STL 0
// Use standard C++ containers to implement all wx container classes.
//
// Default is 1.
@ -299,24 +278,51 @@
//
// Recommended setting: 1.
#define wxUSE_STD_IOSTREAM 1
// Make wxString as much interchangeable with std::[w]string as possible, in
// particular allow implicit conversion of wxString to either of these classes.
// This comes at a price (or a benefit, depending on your point of view) of not
// allowing implicit conversion to "const char *" and "const wchar_t *".
// ----------------------------------------------------------------------------
// wxString-related options
// ----------------------------------------------------------------------------
// Provide unsafe implicit conversions in wxString to "const char*" or
// "std::string" (depending on wxUSE_STD_STRING_CONV_IN_WXSTRING value).
//
// Because a lot of existing code relies on these conversions, this option is
// disabled by default but can be enabled for your build if you don't care
// about compatibility.
// Default is 1 for compatibility reasons, it is recommended to set
// this to 0 because converting wxString to a narrow (non-Unicode) string may
// fail unless a locale using UTF-8 encoding is used, which is never the case
// under MSW, for example, hence such conversions can result in silent data
// loss.
//
// Recommended setting: 1 to remain compatible with the official builds of
// wxWidgets, but define wxNO_UNSAFE_WXSTRING_CONV when compiling the
// application code to effectively disallow using these conversions.
#define wxUSE_UNSAFE_WXSTRING_CONV 1
// Define implicit conversions of wxString to "const wchar_t*" and "const
// char*" if wxUSE_UNSAFE_WXSTRING_CONV is also enabled.
//
// Default is 1.
//
// Recommended setting: 1 to remain compatible with the official builds of
// wxWidgets but may be set to 0 to prevent any accidental conversions from
// happening.
#define wxUSE_CHAR_CONV_IN_WXSTRING 1
// Define implicit conversions of wxString to std::wstring and std::string if
// wxUSE_UNSAFE_WXSTRING_CONV is also enabled.
//
// Note that wxString can always be constructed from std::[w]string, whether
// this option is turned on or off, it only enables implicit conversion in the
// other direction.
//
// Default is 0 if wxUSE_STL has its default value or 1 if it is enabled.
// If this setting is changed to 1, wxUSE_CHAR_CONV_IN_WXSTRING must be set to
// 0 as setting both of them to 1 will result in ambiguities due to having too
// many implicit conversions defined.
//
// Recommended setting: 0 to remain compatible with the official builds of
// wxWidgets.
#define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL
// Default is 0.
//
// Recommended setting: 0, use wxString::ToStdWstring() and ToStdString() or,
// preferably, utf8_string() explicitly instead.
#define wxUSE_STD_STRING_CONV_IN_WXSTRING 0
// ----------------------------------------------------------------------------
// non GUI features selection

View file

@ -117,8 +117,6 @@
#define wxDIALOG_UNIT_COMPATIBILITY 0
#define wxUSE_UNSAFE_WXSTRING_CONV 0
#define wxUSE_REPRODUCIBLE_BUILD 0
@ -157,12 +155,16 @@
#define wxUSE_PRINTF_POS_PARAMS 0
#define wxUSE_STL 0
#define wxUSE_STD_CONTAINERS 0
#define wxUSE_STD_IOSTREAM 0
#define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL
#define wxUSE_UNSAFE_WXSTRING_CONV 0
#define wxUSE_CHAR_CONV_IN_WXSTRING 0
#define wxUSE_STD_STRING_CONV_IN_WXSTRING 0
#define wxUSE_LONGLONG 0

View file

@ -193,11 +193,11 @@ typedef pid_t GPid;
#define wxUSE_PRINTF_POS_PARAMS 0
#define wxUSE_STL 0
#define wxUSE_STD_CONTAINERS 0
#define wxUSE_STD_CONTAINERS wxUSE_STL
#define wxUSE_CHAR_CONV_IN_WXSTRING 1
#define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL
#define wxUSE_STD_STRING_CONV_IN_WXSTRING 0
#define wxUSE_LONGLONG 1

View file

@ -614,23 +614,21 @@ TEST_CASE("StdString::Conversion", "[stdstring]")
wxString s4("hello");
// notice that implicit wxString -> std::string conversion is only
// available in wxUSE_STL case, because it conflicts with conversion to
// const char*/wchar_t*
#if wxUSE_STL && wxUSE_UNSAFE_WXSTRING_CONV
#if wxUSE_STD_STRING_CONV_IN_WXSTRING && wxUSE_UNSAFE_WXSTRING_CONV
std::string s5 = s4;
#else
std::string s5 = s4.ToStdString();
#endif
CHECK( s5 == "hello" );
#if wxUSE_STL
#if wxUSE_STD_STRING_CONV_IN_WXSTRING
std::wstring s6 = s4;
#else
std::wstring s6 = s4.ToStdWstring();
#endif
CHECK( s6 == L"hello" );
#if wxUSE_STD_STRING_CONV_IN_WXSTRING
#if wxUSE_UNSAFE_WXSTRING_CONV
std::string s7(s4);
CHECK( s7 == "hello" );
@ -638,6 +636,7 @@ TEST_CASE("StdString::Conversion", "[stdstring]")
std::wstring s8(s4);
CHECK( s8 == L"hello" );
#endif // wxUSE_STD_STRING_CONV_IN_WXSTRING
std::string s9("\xF0\x9F\x90\xB1\0\xE7\x8C\xAB", 9); /* U+1F431 U+0000 U+732B */
wxString s10 = wxString::FromUTF8(s9);

View file

@ -1018,8 +1018,7 @@ TEST_CASE("StringCStrDataImplicitConversion", "[wxString]")
CHECK( CheckStrConstWChar(s, s.c_str()) );
CHECK( CheckStrConstChar(s, s.c_str()) );
// implicit conversion of wxString is not available in STL build
#if !wxUSE_STL
#if wxUSE_CHAR_CONV_IN_WXSTRING
CHECK( CheckStrConstWChar(s, s) );
#if wxUSE_UNSAFE_WXSTRING_CONV
CHECK( CheckStrConstChar(s, s) );