What is uint8_t?

Source: Internet
Author: User
Tags bool

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 again u again _t. 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 meaning of _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

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.