Ticket #2986: 52-fix-wchar_t-ucs2.diff

File 52-fix-wchar_t-ucs2.diff, 1.3 KB (added by spencer@…, 13 years ago)

Patch showing one way to remove the warnings

  • src/libs/detail/utf8_codecvt_facet.cpp

    old new  
    231231    return 2;
    232232}
    233233
    234 // note the following code will generate on some platforms where
    235 // wchar_t is defined as UCS2.  The warnings are superfluous as
    236 // the specialization is never instantitiated with such compilers.
    237234template<>
    238235int get_cont_octet_out_count_impl<4>(wchar_t word){
    239236    if (word < 0x80) {
     
    242239    if (word < 0x800) {
    243240        return 1;
    244241    }
     242
     243    // Note that the following code will generate warnings on some platforms
     244    // where wchar_t is defined as UCS2.  The warnings are superfluous as the
     245    // specialization is never instantitiated with such compilers, but this
     246    // can cause problems if warnings are being treated as errors, so we guard
     247    // against that.  Including <boost/detail/utf8_codecvt_facet.hpp> as we do
     248    // should be enough to get WCHAR_MAX defined.
     249#if !defined(WCHAR_MAX)
     250#   error WCHAR_MAX not defined!
     251#endif   
     252#if WCHAR_MAX > 0x10000
     253   
    245254    if (word < 0x10000) {
    246255        return 2;
    247256    }
     
    252261        return 4;
    253262    }
    254263    return 5;
     264   
     265#else
     266   
     267    return 2;
     268   
     269#endif
    255270}
    256271
    257272} // namespace anonymous