Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Uint32", "int16" and the like; are they standard c++?

Tags:

c++

I'm quite new to c++, but I've got the hang of the fundamentals. I've come across the use of "Uint32" (in various capitalizations) and similar data types when reading other's code, but I can't find any documentation mentioning them. I understand that "Uint32" is an unsigned int with 32 bits, but my compiler doesn't. I'm using visual c++ express, and it doesn't recognize any form of it from what I can tell.

Is there some compilers that reads those data types by default, or have these programmers declared them themselves as classes or #define constants?

I can see a point in using them to know exactly how long your integer will be, since the normal declaration seems to vary depending on the system. Is there any other pros or cons using them?

like image 688
Zoomulator Avatar asked May 26 '09 14:05

Zoomulator


People also ask

What is UInt32 in C?

In computer programming languages like C and C#, UInt32 is a numeric type that guarantees a 32-bit value. The UInt32 value ranges from 0 to 232 - 1 (4,294,967,295). Similar data types include UInt8, an 8-bit value (range of 0 to 255), and UInt16, a 16-bit value (range of 0 to 65535).

What is uint64_t in C?

The UInt64 value type represents unsigned integers with values ranging from 0 to 184,467,440,737,095,551,615. UInt64 provides methods to compare instances of this type, convert the value of an instance to its string representation, and convert the string representation of a number to an instance of this type.

Where uint32_t is defined?

This type is defined in the C header <stdint.


1 Answers

Unix platforms define these types in stdint.h, this is the preferred method of ensuring type sizing when writing portable code.

Microsoft's platforms do not define this header, which is a problem when going cross-platform. If you're not using Boost Integer Library already, I recommend getting Paul Hsieh's portable stdint.h implementation of this header for use on Microsoft platforms.

Update: Visual Studio 2010 and later do define this header.

like image 140
paxos1977 Avatar answered Oct 06 '22 01:10

paxos1977