K
KevinSimonson
I have been assigned to get the Shareaza source code running and then
to add some functionality to it. The open source is theoretically
what was used to generate a working Shareaza executable, but I'm
finding it kind of hard to believe that this code was actually
compiled. Take this section, for instance:
//! \brief generic function to swap the byte ordering of a given type
//!
//! The byte ordering can be swapped meaningfully only for unsigned
integer types
//! therefore specializations are provided only for those types. We
use
//! template specialization in order to avoid automatic argument
conversion.
template<typename T>
struct SwapEndianess {};
template<> struct SwapEndianess< uint8 >
{
uint8 operator()(uint8 value) const { return value; }
};
template<> struct SwapEndianess< uint16 >
{
uint16 operator()(uint16 value) const
{
return _byteswap_ushort( value );
}
};
template<> struct SwapEndianess< uint32 >
{
uint32 operator()(uint32 value) const
{
return _byteswap_ulong( value );
}
};
template<> struct SwapEndianess< uint64 >
{
uint64 operator()(uint64 value) const
{
return _byteswap_uint64( value );
}
};
template<typename T>
inline T swapEndianess(T value)
{
return SwapEndianess< T >()( value ); // <--- Error!
}
I added the little comment pointing at the error. Of this line the
compiler says,
"1>c:<pathname>\shareaza\hashlib\utility.hpp(221): error C2064: term
does not evaluate to a function taking 1 arguments". Now _it looks to
me_ like the solution to this syntax is just to take out the empty
pair of parentheses, change "return SwapEndianess< T >()( value );" to
"return SwapEndianess< T >( value );". Can anyone see any problem
with me doing that? If it doesn't compile, then I'll know right away,
but I thought I'd better let the readers of this forum know I'm doing
this in case they can see any logical errors that might result from me
doing this. Any pointers will be greatly appreciated.
Kevin S
to add some functionality to it. The open source is theoretically
what was used to generate a working Shareaza executable, but I'm
finding it kind of hard to believe that this code was actually
compiled. Take this section, for instance:
//! \brief generic function to swap the byte ordering of a given type
//!
//! The byte ordering can be swapped meaningfully only for unsigned
integer types
//! therefore specializations are provided only for those types. We
use
//! template specialization in order to avoid automatic argument
conversion.
template<typename T>
struct SwapEndianess {};
template<> struct SwapEndianess< uint8 >
{
uint8 operator()(uint8 value) const { return value; }
};
template<> struct SwapEndianess< uint16 >
{
uint16 operator()(uint16 value) const
{
return _byteswap_ushort( value );
}
};
template<> struct SwapEndianess< uint32 >
{
uint32 operator()(uint32 value) const
{
return _byteswap_ulong( value );
}
};
template<> struct SwapEndianess< uint64 >
{
uint64 operator()(uint64 value) const
{
return _byteswap_uint64( value );
}
};
template<typename T>
inline T swapEndianess(T value)
{
return SwapEndianess< T >()( value ); // <--- Error!
}
I added the little comment pointing at the error. Of this line the
compiler says,
"1>c:<pathname>\shareaza\hashlib\utility.hpp(221): error C2064: term
does not evaluate to a function taking 1 arguments". Now _it looks to
me_ like the solution to this syntax is just to take out the empty
pair of parentheses, change "return SwapEndianess< T >()( value );" to
"return SwapEndianess< T >( value );". Can anyone see any problem
with me doing that? If it doesn't compile, then I'll know right away,
but I thought I'd better let the readers of this forum know I'm doing
this in case they can see any logical errors that might result from me
doing this. Any pointers will be greatly appreciated.
Kevin S