uint8_t / uint16_t / uint32_t / uint64_t in streams

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Mathieu Malaterre (mathieu_at_malaterre.com)
Date: 01/23/05


Date: Sun, 23 Jan 2005 00:49:20 GMT

Hello,

        I am trying to defines those types with Visual Studio C++, since it
does not provide stdint.h (C99).

        Anyway I thought this was the rigth approach:

#if defined(_MSC_VER)
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef signed __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#endif

        Unfortunately I cannot use streams anymore. Extract of the warnings/errors:

error C2679: binary '>>' : no operator defined which takes a right-hand
operand of type 'unsigned __int16' (or there is no acceptable conversion)

or I get:

error C2593: 'operator <<' is ambiguous

        What is the correct way of defining those types then ?

Thanks for any help
Mathieu

For further reference I read the thread:
[print __int64 via ostream cout]
http://groups-beta.google.com/group/microsoft.public.vc.language/browse_thread/thread/13303e3156da08f7/c5db0b2605e66318

But it seems you cannot do anything if you lead those types with
keyword: 'unsigned'



Relevant Pages