I recently ran into an issue where I was trying to serialize a bool variable from a CArchive object.
Archiving it out, with this code, works fine:
ar << bFill;
But this code:
ar >> bFill
has problems. It compiles fine under Visual Studio 2003, but errors out under Visual C++ 6 with this error:
C2679: binary ‘>>’
: no operator defined which takes a right-hand operand of type ‘bool’
(or there is no acceptable conversion)
Very weird. There is some explanation here.
My resolution? Use BOOL instead. Sure, it’s actually an int and takes 4 bytes, not 1, but that’s a not a big deal in this case. And it’s more clear than using BYTE.