On Tue, Jan 10, 2017 at 8:54 AM, PB <
pbfo...@gmail.com> wrote:
> Hi,
>
> regarding wxString and std::(w)string. As Stephan above indicated, at least
> on Windows, the behaviour is controlled by (at least) two compile-time
> options. In WXWIN\include\wx\msw\setup.h there is:
>> // Default is 0 if wxUSE_STL has its default value or 1 if it is enabled.
>> //
>> // Recommended setting: 0 to remain compatible with the official builds of
>> // wxWidgets.
>> #define wxUSE_STD_STRING_CONV_IN_WXSTRING wxUSE_STL
Thanks to you and Stephan, but that doesn't seem to be it: with some
suitable #ifdef and #error preprocessor directives I find that
wxUSE_STD_STRING_CONV_IN_WXSTRING does seem to be set to 0 (zero) in
our builds for both Linux and Windows.
Now, an interesting observation is that if on Windows, I build with
CXX=clang-cl (Clang's VS-compatibility-emulating wrapper, Clang
version 3.9.0) using essentially the same compiler flags, I get the
sorts of errors shown below that mention various wxString conversion
operators.
So I wonder if what is happening is that VS 2015 follows a two-step
path first from some wxString conversion operator to a pointer type,
and then from std::string's constructor from a char pointer? Not sure
why this would work in VS 2012 and 2015 but not in other compilers
(the usual lack of standards-compliance in VS perhaps??) but that's
the only thing I can come up with, in which case it might be difficult
to get this fixed ...
Clang errors follow:
.\testfile.cpp(215,17): error: no viable conversion from 'wxString'
to 'std::string' (aka 'basic_string<char, char_traits<char>,
allocator<char> >')
std::string x = wxString();
^ ~~~~~~~~~~
C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\INCLUDE\xstring(775,2): note: candidate constructor not
viable: no known conversion from 'wxString' to 'const _Myt &' (aka
'const basic_string<char, std::char_traits<char>, std::allocator<char>
> &') for 1st argument
basic_string(const _Myt& _Right)
^
C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\INCLUDE\xstring(834,2): note: candidate constructor not
viable: no known conversion from 'wxString' to 'const char *' for 1st
argument
basic_string(const _Elem *_Ptr)
^
C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\INCLUDE\xstring(909,2): note: candidate constructor not
viable: no known conversion from 'wxString' to '_Myt &&' (aka
'basic_string<char, std::char_traits<char>, std::allocator<char> >
&&') for 1st argument
basic_string(_Myt&& _Right) _NOEXCEPT
^
C:\Program Files (x86)\Microsoft Visual Studio
14.0\VC\INCLUDE\xstring(975,2): note: candidate constructor not
viable: no known conversion from 'wxString' to
'::std::initializer_list<char>' for 1st argument
basic_string(_XSTD initializer_list<_Elem> _Ilist,
^
d:\wxMSW-3.1.0\include\wx/string.h(1498,5): note: candidate function
operator wxCStrData() const { return c_str(); }
^
d:\wxMSW-3.1.0\include\wx/string.h(1507,5): note: candidate function
operator const char*() const { return c_str(); }
^
d:\wxMSW-3.1.0\include\wx/string.h(1508,5): note: candidate function
operator const wchar_t*() const { return c_str(); }
^
d:\wxMSW-3.1.0\include\wx/string.h(1513,5): note: candidate function
operator const void*() const { return c_str(); }
^
1 error generated.