Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand int8_t and int64_t and size_t and size_t

Shulou Source: shulou.com Published: 2022-06-03 13:14:20 09月17日 Update

This article introduces how to understand int8_t and int64_t and size_t and ssize_t. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

Uint8_t and so on.

So what exactly does t mean? The specific official answer has not been found, but I think one is relatively close. It is a structural annotation, which can be understood as an abbreviation for type/typedef, indicating that it is defined through typedef rather than other data types. Since none of them are new data types, they are just aliases for types using typedef, so why do you need to define them? Because different platforms have different word lengths across platforms, using precompilation and typedef allows you to maintain your code most effectively.

They are defined in the stdint.h header file, and the following code is copied from / usr/include/stdint.h

/ * There is some amount of overlap with as known by inet code * / # ifndef _ _ int8_t_defined# define _ _ int8_t_definedtypedef signed char int8_t;typedef short int int16_t;typedef int int32_t;# if _ WORDSIZE = = 64typedef long int int64_t;# else__extension__typedef long long int int64_t;# endif#endif/* Unsigned. * / typedef unsigned char uint8_t;typedef unsigned short int uint16_t;#ifndef _ _ uint32_t_definedtypedef unsigned int uint32_t;# define _ _ uint32_t_defined#endif#if _ WORDSIZE = = 64typedef unsigned long int uint64_t;#else__extension__typedef unsigned long long int uint64_t;#endif

After reading the above code, you will have a clear understanding of uint8_t and so on.

Size_t/ssize_t

With regard to size_t/ssize_t, anxious students can look at the conclusion first.

Size_t unsigned integer 32bit system is equivalent to unsigned int 64bit system is equivalent to unsigned long int.

Ssize_t signed integer 32bit system is equivalent to int 64bit system is equivalent to long int.

In the 32bit system, long int is 32bit, and in the 64bit system, long int is 64bit.

You can look at / usr/include/sys/types.h layer by layer, and eventually you'll find the definitions of ssize_t and size_t.

How to judge the number of system digits

Getconf WORD_BIT

Getconf LONG_BIT

Or use uname-a

On how to understand int8_t and int64_t and size_t as well as ssize_t to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: System code type different content data more symbol answer face help good effective anxious digit interest alias just classmate official Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Information Xiaomi macOS MySQL