Reputation: 4251
I want to use U32 type but I can't find the header where it is defined. Does anyone know?
Upvotes: 3
Views: 34737
Reputation: 75130
There is no standard type called U32
, but if you #include <cstdint>
(stdint.h
for C) you can use std::uint32_t
1, a 32 bit unsigned integer, which is (I assume) what you want.
Here is a list of types in the cstdint
header:
namespace std {
int8_t
int16_t
int32_t
int64_t
int_fast8_t
int_fast16_t
int_fast32_t
int_fast64_t
int_least8_t
int_least16_t
int_least32_t
int_least64_t
intmax_t
intptr_t
uint8_t
uint16_t
uint32_t
uint64_t
uint_fast8_t
uint_fast16_t
uint_fast32_t
uint_fast64_t
uint_least8_t
uint_least16_t
uint_least32_t
uint_least64_t
uintmax_t
uintptr_t
}
1 Thanks Martinho Fernandes for pointing out that these types are in the namespace std
.
Upvotes: 16
Reputation: 155
U32 is an idiomatic shortcut for an unsigned int. Its common definition is:
typedef unsigned int U32;
But the main reason for its use is to be able to control the actual definition manually. Hope this helps.
Upvotes: 2
Reputation: 57555
While cstdint might be a solution, it's not universal -- MSVC versions before 2010 didn't ship with that one. If writing for multiple platforms you'll need to supply the standard types yourself if MSVC < 2010 is detected. Or use the boost one if you use boost.
Upvotes: 2