[conversion] wchar_t support in lexical_cast

Hi, I'm trying to get boost working for x86_64 and Itanium on Windows. The result environment combination is rather strange: Platform SDK contains old Dinkumware STL and new compiler (14.0). So, the biggest problems is that I have to compile it without native wchar_t support. And lexical_cast is one of places where a problem exists: #if defined(BOOST_NO_STRINGSTREAM) || \ defined(BOOST_NO_STD_WSTRING) || \ defined(BOOST_NO_STD_LOCALE) || \ defined(BOOST_NO_INTRINSIC_WCHAR_T) #define DISABLE_WIDE_CHAR_SUPPORT #endif You can see that wchar_t support is disabled compeletely in lexical_cast if wchar_t is not available as a native type. Why is it so? It seems that I got it working if I change it to #if defined(BOOST_NO_STRINGSTREAM) || \ defined(BOOST_NO_STD_WSTRING) || \ defined(BOOST_NO_STD_LOCALE) #define DISABLE_WIDE_CHAR_SUPPORT #endif But probably there are some caveats here. What are they? -- Alexei Alexandrov

Alexei Alexandrov wrote:
But probably there are some caveats here. What are they?
Non-native wchar_t issues aside (I'm not sure of the rationale here), if the compiler is, as you say, new, then it should have an intrinsic wchar_t, and failure to get it working is either misconfiguration of the compiler (VC++, for example, needs a compiler switch to activate intrinsic wchar_t) or misconfiguration in the Boost config.hpp. Sebastian Redl

Sebastian Redl wrote:
Non-native wchar_t issues aside (I'm not sure of the rationale here), if the compiler is, as you say, new, then it should have an intrinsic wchar_t, and failure to get it working is either misconfiguration of the compiler (VC++, for example, needs a compiler switch to activate intrinsic wchar_t) or misconfiguration in the Boost config.hpp.
...or the situation is not that simple, e.g. if your STL doesn't work at all with native wchar_t. ;-) Stefan

Hi Sebastian Redl, you wrote:
Non-native wchar_t issues aside (I'm not sure of the rationale here), if the compiler is, as you say, new, then it should have an intrinsic wchar_t, and failure to get it working is either misconfiguration of the compiler (VC++, for example, needs a compiler switch to activate intrinsic wchar_t) or misconfiguration in the Boost config.hpp.
My problem is that STL is old and its pre-compiled parts (with pre-compiled specializations for basic_string<wchar_t> etc.) know nothing about native wchar_t. So if I pass that compiler switch I'll get a bunch of linker errors. As expected. This is why I need to get it working with "unsigned short" wchar_t. -- Alexei Alexandrov

#include <boost/random.hpp> #include <time.h> int main () { boost::variate_generator<boost::mt19937, boost::uniform_int<> > tf(boost::mt19937(time(NULL)),boost::uniform_int<>(0,1)); } boost 1.31.1 random g++ (GCC) 3.4.3 20050227 (Red Hat 3.4.3-22.1) No Errors g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-42): multi.cc: In function `int main()': multi.cc:6: syntax error before numeric constant __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

#include <boost/variant.hpp> #include <boost/multi_array.hpp> typedef boost::variant< double, std::string > Variant_t; typedef boost::multi_array<Variant_t, 2> Array2d_t; typedef boost::multi_array<Variant_t, 1> Array1d_t; // not sure if this is even legal int main () { Array2d_t A(boost::extents[3][4]); for(Array2d_t::iterator i = A.begin(); i != A.end(); ++i) for(Array1d_t::iterator j = i->begin(); j != i->end(); ++j) *j=Variant_t(1.1); return 0; } boost 1.31.1 and multi_array for variants for g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-42): No Errors g++ (GCC) 3.4.3 20050227 (Red Hat 3.4.3-22.1) /local/boost/1.33.1/common/include/boost-1_33_1/boost/iterator/iterator_facade.hpp: In function `typename boost::detail::enable_if_interoperable<Derived1, Derived2, typename boost::mpl::apply2<boost::detail::always_bool2, Derived1, Derived2>::type>::type boost::operator!=(const boost::iterator_facade<Derived1, V1, TC1, R1, D1>&, const boost::iterator_facade<Derived2, V2, TC2, R2, D2>&) [with Derived1 = boost::detail::multi_array::array_iterator<Variant_t, Variant_t*, mpl_::size_t<2u>, boost::detail::multi_array::sub_array<Variant_t, 1u> >, V1 = boost::multi_array<Variant_t, 1u, std::allocator<Variant_t> >, TC1 = boost::random_access_traversal_tag, R1 = boost::detail::multi_array::sub_array<Variant_t, 1u>, D1 = ptrdiff_t, Derived2 = boost::detail::multi_array::array_iterator<Variant_t, Variant_t*, mpl_::size_t<2u>, boost::detail::multi_array::sub_array<Variant_t, 1u> >, V2 = boost::multi_array<Variant_t, 1u, std::allocator<Variant_t> >, TC2 = boost::random_access_traversal_tag, R2 = boost::detail::multi_array::sub_array<Variant_t, 1u>, D2 = ptrdiff_t]': multi.cc:12: instantiated from here /local/boost/1.33.1/common/include/boost-1_33_1/boost/iterator/iterator_facade.hpp:840: error: dependent-name ` boost::is_convertible<Derived2,Derived1>::type' is parsed as a non-type, but instantiation yields a type /local/boost/1.33.1/common/include/boost-1_33_1/boost/iterator/iterator_facade.hpp:840: note: say `typename boost::is_convertible<Derived2,Derived1>::type' if a type is meant /local/boost/1.33.1/common/include/boost-1_33_1/boost/iterator/iterator_facade.hpp: In function `typename boost::detail::enable_if_interoperable<Derived1, Derived2, typename boost::mpl::apply2<boost::detail::always_bool2, Derived1, Derived2>::type>::type boost::operator!=(const boost::iterator_facade<Derived1, V1, TC1, R1, D1>&, const boost::iterator_facade<Derived2, V2, TC2, R2, D2>&) [with Derived1 = boost::detail::multi_array::array_iterator<Variant_t, Variant_t*, mpl_::size_t<1u>, Variant_t&>, V1 = Variant_t, TC1 = boost::random_access_traversal_tag, R1 = Variant_t&, D1 = ptrdiff_t, Derived2 = boost::detail::multi_array::array_iterator<Variant_t, Variant_t*, mpl_::size_t<1u>, Variant_t&>, V2 = Variant_t, TC2 = boost::random_access_traversal_tag, R2 = Variant_t&, D2 = ptrdiff_t]': multi.cc:13: instantiated from here /local/boost/1.33.1/common/include/boost-1_33_1/boost/iterator/iterator_facade.hpp:840: error: dependent-name ` boost::is_convertible<Derived2,Derived1>::type' is parsed as a non-type, but instantiation yields a type /local/boost/1.33.1/common/include/boost-1_33_1/boost/iterator/iterator_facade.hpp:840: note: say `typename boost::is_convertible<Derived2,Derived1>::type' if a type is meant make: *** [multi] Error 1 __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com

Paul Joseph Panaro wrote:
g++ (GCC) 3.4.3 20050227 (Red Hat 3.4.3-22.1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [Errors snipped]
The underlined part seems to be the cause of this problem. Your code compiles fine with vanilla gcc 3.4.3. Regards, m Send instant messages to your online friends http://au.messenger.yahoo.com

Paul Joseph Panaro <pjpanaro@yahoo.com> writes:
#include <boost/variant.hpp> #include <boost/multi_array.hpp>
typedef boost::variant< double, std::string > Variant_t; typedef boost::multi_array<Variant_t, 2> Array2d_t; typedef boost::multi_array<Variant_t, 1> Array1d_t;
// not sure if this is even legal int main () { Array2d_t A(boost::extents[3][4]);
for(Array2d_t::iterator i = A.begin(); i != A.end(); ++i) for(Array1d_t::iterator j = i->begin(); j != i->end(); ++j) *j=Variant_t(1.1);
return 0; }
boost 1.31.1 and multi_array for variants
for g++ (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-42): No Errors
g++ (GCC) 3.4.3 20050227 (Red Hat 3.4.3-22.1)
I just compiled your program with Cygwin G++ 3.4.4 using the Boost CVS. I suggest first upgrading your compiler and then, if that doesn't work, your Boost. -- Dave Abrahams Boost Consulting www.boost-consulting.com

Alexei Alexandrov wrote:
Hi,
I'm trying to get boost working for x86_64 and Itanium on Windows. The result environment combination is rather strange: Platform SDK contains old Dinkumware STL and new compiler (14.0). So, the biggest problems is that I have to compile it without native wchar_t support. And lexical_cast is one of places where a problem exists:
[...] This was already done by John Maddock but it didn't make it into 1.33.0. Maybe you can get the file from CVS. Stefan Revision : 1.19 Date : 2005/8/29 12:43:15 Author : 'johnmaddock' State : 'Exp' Lines : +3 -2 Description : Reconfigure lexical_cast to work wide character strings and VC++ when not using /Zc:wchar_t.
participants (6)
-
Alexei Alexandrov
-
David Abrahams
-
Martin Wille
-
Paul Joseph Panaro
-
Sebastian Redl
-
Stefan Slapeta