Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are types like uint32, int32, uint64, int64 defined in any stdlib header?

Tags:

c

libc

I often see source code using types like uint32, uint64 and I wonder if they should be defined by the programmer in the application code or if they are defined in a standard lib header.

What's the best way to have these types on my application source code?

like image 630
philix Avatar asked May 16 '11 04:05

philix


People also ask

What is Int64 in C?

Int64: This Struct is used to represents 64-bit signed integer. The Int64 can store both types of values including negative and positive between the ranges of -9,223,372,036,854,775,808 to +9, 223,372,036,854,775,807. Example : C#

Where is uint32_t defined?

This type is defined in the C header <stdint. h> which is part of the C++11 standard but not standard in C++03. According to the Wikipedia page on the header, it hasn't shipped with Visual Studio until VS2010. Hope this helps!

What is UInt32?

The UInt32 value type represents unsigned integers with values ranging from 0 to 4,294,967,295. UInt32 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.


3 Answers

The C99 stdint.h defines these:

  • int8_t
  • int16_t
  • int32_t
  • uint8_t
  • uint16_t
  • uint32_t

And, if the architecture supports them:

  • int64_t
  • uint64_t

There are various other integer typedefs in stdint.h as well.

If you're stuck without a C99 environment then you should probably supply your own typedefs and use the C99 ones anyway.

The uint32 and uint64 (i.e. without the _t suffix) are probably application specific.

like image 103
mu is too short Avatar answered Oct 16 '22 18:10

mu is too short


Those integer types are all defined in stdint.h

like image 38
GWW Avatar answered Oct 16 '22 17:10

GWW


If you are using C99 just include stdint.h. BTW, the 64bit types are there iff the processor supports them.

like image 2
BiGYaN Avatar answered Oct 16 '22 18:10

BiGYaN