Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between uint32 and uint32_t [duplicate]

Possible Duplicate:
Difference between different integer types

What is the difference between uint32 and uint32_t in C/C++?

Are they OS-dependent?

In which case should I use one or another?

like image 528
Maxbester Avatar asked Nov 13 '12 14:11

Maxbester


People also ask

What is the difference between uint32_t and UInt32?

typedef unsigned integer type uint32_t; // optional //... } uint32 is not, it's a shortcut provided by some compilers (probably as typedef uint32_t uint32 ) for ease of use. More likely as a typedef for something that was known to be an unsigned 32 bit integer at a time before <cstdint> was standard.

What is uint32_t?

uint32_t is a numeric type that guarantees 32 bits. The value is unsigned, meaning that the range of values goes from 0 to 232 - 1. This. uint32_t* ptr; declares a pointer of type uint32_t* , but the pointer is uninitialized, that is, the pointer does not point to anywhere in particular.

What is the difference between unsigned int and uint32_t?

uint32_t (or however pre-C++11 compilers call it) is guaranteed to be a 32-bit unsigned integer; unsigned int is whatever unsigned integer the compiler likes best to call unsigned int , as far as it meets the requirements of the standard (which demands for it a 0-65535 minimum range).

Is uint32_t the same as unsigned long?

You are likely wondering what are uint8_t, uint16_t, uint32_t and uint64_t. That's a good question. Because it could be really helpul! It turns out that they are equal respectively to: unsigned char, unsigned short, unsigned int and unsigned long long.


1 Answers

uint32_t is standard, uint32 is not. That is, if you include <inttypes.h> or <stdint.h>, you will get a definition of uint32_t. uint32 is a typedef in some local code base, but you should not expect it to exist unless you define it yourself. And defining it yourself is a bad idea.

like image 52
William Pursell Avatar answered Oct 03 '22 17:10

William Pursell