Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2005-01-20 11:07:50


I'm sure some of this was contributed for me. I found the namespace of
mbstate_t to vary all over the place for different libraries and we kept
patching it for every case. So its not a surprise that it needs cleaning
up. Please try to make sure that it still works after its cleaned up.

Robert Ramey

Vladimir Prus wrote:
> On Thursday 06 January 2005 16:38, John Maddock wrote:
>> The following section of code in utf8_codecvt_factet.hpp seems to be
>> rather mixed up:
>>
>> #if BOOST_WORKAROUND(__BORLANDC__,BOOST_TESTED_AT(0x551))
>> #ifndef _RWSTD_NO_NAMESPACE
>> using std::codecvt;
>> using std::min;
>> #ifdef _RWSTD_NO_MBSTATE_T
>> using std::mbstate_t;
>> #endif
>> #endif
>>
>> This section imports codecvt, min and mbstate_t into the *global
>> namespace*, why?
>
> I don't know. This was a fix sent by an user (Pavel Vozenilek, I
> think) for some specific borland version. We failed to figure out why
> this works and what's the exact problem with that compiler.
>
>> Isn't this a "bad thing" in general?
>
> I don't think so, in general. mbstate_t was in global namespace in C,
> after all.
>
>> I can't see why it would be necessary anyway.
>>
>> #elif defined(__COMO__) || defined(_MSC_VER) && _MSC_VER <= 1300
>> typedef ::mbstate_t mbstate_t;
>>
>> Surely this has no effect at best, or is illegal at worst? Remember
>> we're in the global namespace here.
>> Commenting this out has no effect on VC7 BTW
>> (and VC6 doesn't build the lib anyway), can't comment on Commeau
>> though.
>>
>> #elif defined(BOOST_NO_STDC_NAMESPACE)
>> typedef std::mbstate_t mbstate_t;
>> namespace std{
>> using ::codecvt;
>>
>> Again why import mbstate_t into the global namespace, especially as
>> this does not happen for std conforming compilers?
>
> Pavel, seems like the std::mbstate_t -> mbstate_t change was part of
> your patch (applied in revision 1.10 of utf_codecvt_facet.hpp). Do
> you remember why it was necessary?
>
>> Finally importing codecvt into namespace std:: is almost always
>> likely to be an error: BOOST_NO_STDC_NAMESPACE refers to C library
>> code, I don't know of any std lib that has codecvt, but doesn't put
>> it in namespace std already.
>>
>> In any case it doesn't build as is with gcc-2.95 (with or without
>> STLport), but changing that to:
>>
>> #elif defined(BOOST_NO_STDC_NAMESPACE)
>> namespace std{
>> using ::mbstate_t;
>> } // namespace std
>>
>> and likewise changing the similar workaround convert.hpp to:
>>
>> #if BOOST_WORKAROUND(__ICL, <= 700) ||
>> defined(BOOST_NO_STDC_NAMESPACE) #include <wchar.h>
>> namespace std
>> {
>> using ::mbstate_t;
>> }
>> #endif
>>
>> Gets it compiling with gcc-2.95 + STLport.
>>
>> Hope this helps,
>
> Yes, it does. Thank you!
> I'm just now trying to merge workarounds in program_options' and
> serialization's version of that file, so your suggestions are very
> welcome.
>
> - Volodya
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk