What is UIntPtr Golang?


Type uintptr in Golang

uintptr in Golang is an integer type that is large enough to contain the bit pattern of any pointer, representing a memory address.

uint64_t in C

In C, uint64_t is an unsigned integer type that can hold values from 0 to 18,446,744,073,709,551,615.

Data Size Comparison

Type Bytes Range of Values
long 4 -2,147,483,648 to 2,147,483,647
unsigned long 4 0 to 4,294,967,295
long long 8 -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
unsigned long long 8 0 to 18,446,744,073,709,551,615

Linux Data Types

  • size_t: 4 bytes
  • time_t: 4 bytes
  • clock_t: 4 bytes
  • wchar_t: 4 bytes on UNIX and Linux (2 bytes on AIX).

Relationship Between size_t and uint64_t

uint64_t is always 64-bit, while size_t size varies depending on machines/architectures. There is no direct connection between the two types.

Arithmetic with size_t

size_t is typically used for loop, array indexing, size storage, and address arithmetic purposes. While it can store a pointer, uintptr_t is more suitable for this role.

Lascia un commento