taglib fails to compile with MS VC++ 2010
Tanguy Krotoff
tkrotoff at gmail.com
Sat Jan 22 19:49:52 CET 2011
I don't get any warning when compiling mpegheader.cpp with this patch
under Mac OS X SL (64 bits) with gcc 4.2.1 and -Wall -Wextra
I don't remember to get a warning neither with MinGW under Windows XP (32 bits).
Once compiled TagLib works fine as usual on both OS.
I didn't try with an old version of Visual C++ (don't have one installed)
The original value is of type uint (32 bits) cast to ulonglong (64
bits) and then cast to ulong (32 bits) (in the case of the original
bitset constructor). Since ulong is the same length as uint I don't
see any problem.
+ I guess the guys behind C++0x have tested this case when they have
done the modification to bitset constructor.
To be sure I think the best is for you to check on your computer if
you get any warning related to "loss of precision" when compiling
mpegheader.cpp and friends with this patch.
2011/1/21 Lukáš Lalinský <lalinsky at gmail.com>:
> 2011/1/21 Tanguy Krotoff <tkrotoff at gmail.com>:
>> ** Summary: yes this patch is perfect! it makes the code compliant
>> with the new version C++0x (still to be released)
>
> Thanks, I'd just like to confirm one more detail. Will the old version
> not complain when it has to convert "unsigned long long" to "unsigned
> long", i.e. something about losing precision?
>
> Lukas
>
>> ** More details:
>>
>> The error simplified is:
>> mpegheader.cpp(172) : error C2668: 'std::bitset<_Bits>::bitset' :
>> ambiguous call to overloaded function
>> C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\bitset(136):
>> could be 'std::bitset<_Bits>::bitset(_ULonglong)'
>> C:\Program Files\Microsoft Visual Studio 10.0\VC\INCLUDE\bitset(127):
>> or 'std::bitset<_Bits>::bitset(int)'
>> while trying to match the argument list '(TagLib::uint)'
>>
>> This is Visual C++ 2008 bitset constructor:
>> http://msdn.microsoft.com/en-us/library/zfae7kt8(v=VS.90).aspx
>> bitset(
>> unsigned long _Val
>> );[...]
>>
>> This is Visual C++ 2010 bitset constructor:
>> http://msdn.microsoft.com/en-us/library/zfae7kt8(v=VS.100).aspx
>> bitset(
>> unsigned long long _Val
>> );
>>
>> This is a change due to the new C++ version C++0x (still to be
>> released...) cf bitset source code from Visual C++ 2010 on my hard
>> drive (see http://www.codeguru.com/cpp/article.php/c18259 for more
>> explanations about _HAS_CPP0X):
>>
>> [...]
>> #if _HAS_CPP0X
>> bitset(int _Ival) <-------- line 127
>> { // construct from bits in int
>> unsigned int _Val = (unsigned int)_Ival;
>> _Tidy();
>> for (size_t _Pos = 0; _Val != 0 && _Pos < _Bits; _Val >>= 1, ++_Pos)
>> if (_Val & 1)
>> set(_Pos);
>> }
>>
>> bitset(_ULonglong _Val) <-------- line 136
>>
>> #else /* _HAS_CPP0X */
>> bitset(unsigned long _Val)
>> #endif /* _HAS_CPP0X */
>> [...]
>>
>> More explanations about this change in C++0x :
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2795.html#694
>> "[...]replace the bitset ctor that takes an unsigned long argument
>> with one taking unsigned long long in the definition of the template"
>>
>>
>>
>> 2011/1/16 Lukáš Lalinský <lalinsky at gmail.com>:
>>> On Fri, Jan 14, 2011 at 11:05 AM, Tanguy Krotoff <tkrotoff at gmail.com> wrote:
>>>> Hi everybody.
>>>>
>>>> Any chance to get this patch on trunk?
>>>
>>> I'll commit it, but can somebody please explain to me why is it
>>> necessary to cast the value to "unsigned long long". From what I can
>>> see, the std::bitset class has only "unsigned long" constructor.
>>> Shouldn't it be casted to "unsigned long" instead?
>>>
>>> Lukas
> _______________________________________________
> taglib-devel mailing list
> taglib-devel at kde.org
> https://mail.kde.org/mailman/listinfo/taglib-devel
>
More information about the taglib-devel
mailing list