uint8_t/uint16_t/uint32_t/uint64_t is what data type-big summary, see completely understand

Source: Internet
Author: User

Transferred from: http://blog.csdn.net/kiddy19850221/article/details/6655066

What data types are uint8_t/uint16_t/uint32_t/uint64_t

In Nesc's code, you'll see a lot of data types you don't know, such as uint8_t. At first glance, it seems like a new data type, but the C language (Nesc is the extension of C) doesn't seem to have this type of data! How come you are _t again? Many people have this kind of doubt. On the Forum, someone asked: is the type with the end of *_t a long type? Baidu on the search, only to find the answer, then found that the original oneself to C too little mastery.

So what does the _t mean? The specific official answer was not found, but I think there is a close answer. It is a structure callout, which can be understood as an abbreviation of Type/typedef, indicating that it is defined by a TypeDef, not other data types.

Uint8_t,uint16_t,uint32_t and so are not new data types, they just use typedef to the type of alias, new bottle of wine tricks. However, do not underestimate the TypeDef, it will have a good role in the maintenance of your code. For example, there is no bool in C, so in a software, some programmers use int, some programmers use short, it is more chaotic, it is best to use a typedef to define, such as:
typedef char BOOL;

In general, a C project must do some of this work, because you will be involved in cross-platform, different platforms will have different word length, so the use of pre-compilation and typedef can make you the most effective maintenance of your code. For the convenience of users, C99 standard C language hardware for us to define these types, we are assured that the use of it.

According to the POSIX standard, the *_t type corresponding to the generic shaping is:
1 bytes uint8_t
2 bytes uint16_t
4 bytes uint32_t
8 bytes uint64_t

Attached: Contents of inttypes.h in C99 standard
00001/*
00002 Inttypes.h
00003
00004 Contributors:
00005 createdby Marek Michalkiewicz <[email protected]>
00006
00007 Thissoftware is not copyrighted
00008
00009 Thissource code is offered for use on the public domain. May
00010 use,modify or distribute it freely.
00011
00012 Thiscode is distributed on the hope that it'll be useful, but
00013 Withoutany WARRANTY. Allwarranties, EXPRESS OR implied is hereby
00014 disclaimed. This includes but isn't limited towarranties of
00015 Merchantabilityor FITNESS for A particular PURPOSE.
00016 */
00017
00018 #ifndef __inttypes_h_
00019 #define __inttypes_h_
00020
00021/* Use [u]intn_t if you need exactly N bits.
00022 xxx-doesn ' t handle the-mint8 option. */
00023
00024 typedefsigned Char int8_t;
00025 typedefunsigned Char uint8_t;
00026
00027 Typedefint int16_t;
00028 typedefunsigned int uint16_t;
00029
00030 Typedeflong int32_t;
00031 typedefunsigned long uint32_t;
00032
00033 Typedeflong long int64_t;
00034 typedefunsigned Long Long uint64_t;
00035
00036 typedefint16_t intptr_t;
00037 typedefuint16_t uintptr_t;
00038
00039 #endif

What data type is

uint8_t/uint16_t/uint32_t/uint64_t-Big summary, see fully understood

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.