3

I want to use U32 type but I can't find the header where it is defined. Does anyone know?

Tiago Costa
  • 4,151
  • 12
  • 36
  • 54

3 Answers3

15

There is no standard type called U32, but if you #include <cstdint> (stdint.h for C) you can use std::uint32_t1, 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.

anatolyg
  • 26,506
  • 9
  • 60
  • 134
Seth Carnegie
  • 73,875
  • 22
  • 181
  • 249
2

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.

user46748
  • 145
  • 2
  • 4
2

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.

Kornel Kisielewicz
  • 55,802
  • 15
  • 111
  • 149