日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程语言 > c/c++ >内容正文

c/c++

[cpp]c++中的 _t 类的数据类型

發(fā)布時(shí)間:2025/4/5 c/c++ 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [cpp]c++中的 _t 类的数据类型 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

文章目錄

    • 1. 簡(jiǎn)介
    • 2.例子
    • 3.Reference

1. 簡(jiǎn)介

_t 類的數(shù)據(jù)結(jié)構(gòu)大都是用 typedef 來定義的,主要用于跨平臺(tái)時(shí),平臺(tái)字長(zhǎng)不一,會(huì)造成代碼不好維護(hù)的情況。

2.例子

一般整型對(duì)應(yīng)的 *_t 類型有:

  • unit8_t – 1 byte
  • unit16_t – 2 byte
  • unit32_t – 4 byte
  • unit64_t – 8 byte

下面是一個(gè)與 c99標(biāo)準(zhǔn)中的一個(gè) int_types.h 相類似的定義文件:

bash-3.00$ vi int_types.h "int_types.h" [Read only] 176 lines, 4367 characters /** Copyright 2004 Sun Microsystems, Inc. All rights reserved.* Use is subject to license terms.*/#ifndef _SYS_INT_TYPES_H #define _SYS_INT_TYPES_H#pragma ident "@(#)int_types.h 1.10 04/09/28 SMI"/** This file, <sys/int_types.h>, is part of the Sun Microsystems implementation* of <inttypes.h> defined in the ISO C standard, ISO/IEC 9899:1999* Programming language - C.** Programs/Modules should not directly include this file. Access to the* types defined in this file should be through the inclusion of one of the* following files:** <sys/types.h> Provides only the "_t" types defined in this* file which is a subset of the contents of* <inttypes.h>. (This can be appropriate for* all programs/modules except those claiming* ANSI-C conformance.)** <sys/inttypes.h> Provides the Kernel and Driver appropriate* components of <inttypes.h>.** <inttypes.h> For use by applications.** See these files for more details.*/#include <sys/feature_tests.h>#ifdef __cplusplus extern "C" { #endif/** Basic / Extended integer types** The following defines the basic fixed-size integer types.** Implementations are free to typedef them to Standard C integer types or* extensions that they support. If an implementation does not support one* of the particular integer data types below, then it should not define the* typedefs and macros corresponding to that data type. Note that int8_t* is not defined in -Xs mode on ISAs for which the ABI specifies "char"* as an unsigned entity because there is no way to define an eight bit* signed integral.*/ #if defined(_CHAR_IS_SIGNED) typedef char int8_t; #else #if defined(__STDC__) typedef signed char int8_t; #endif #endif typedef short int16_t; typedef int int32_t; #ifdef _LP64 #define _INT64_TYPE typedef long int64_t; #else /* _ILP32 */ #if defined(_LONGLONG_TYPE) #define _INT64_TYPE typedef long long int64_t; #endif #endiftypedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; #ifdef _LP64 typedef unsigned long uint64_t; #else /* _ILP32 */ #if defined(_LONGLONG_TYPE) typedef unsigned long long uint64_t; #endif #endif/** intmax_t and uintmax_t are to be the longest (in number of bits) signed* and unsigned integer types supported by the implementation.*/ #if defined(_INT64_TYPE) typedef int64_t intmax_t; typedef uint64_t uintmax_t; #else typedef int32_t intmax_t; typedef uint32_t uintmax_t; #endif/** intptr_t and uintptr_t are signed and unsigned integer types large enough* to hold any data pointer; that is, data pointers can be assigned into or* from these integer types without losing precision.*/ #if defined(_LP64) || defined(_I32LPx) typedef long intptr_t; typedef unsigned long uintptr_t; #else typedef int intptr_t; typedef unsigned int uintptr_t; #endif/** The following define the fastest integer types that can hold the* specified number of bits.*/ #if defined(_CHAR_IS_SIGNED) typedef char int_fast8_t; #else #if defined(__STDC__) typedef signed char int_fast8_t; #endif #endif typedef int int_fast16_t; typedef int int_fast32_t; #ifdef _LP64 typedef long int_fast64_t; #else /* _ILP32 */ #if defined(_LONGLONG_TYPE) typedef long long int_fast64_t; #endif #endiftypedef unsigned char uint_fast8_t; typedef unsigned int uint_fast16_t; typedef unsigned int uint_fast32_t; #ifdef _LP64 typedef unsigned long uint_fast64_t; #else /* _ILP32 */ #if defined(_LONGLONG_TYPE) typedef unsigned long long uint_fast64_t; #endif #endif/** The following define the smallest integer types that can hold the* specified number of bits.*/ #if defined(_CHAR_IS_SIGNED) typedef char int_least8_t; #else #if defined(__STDC__) typedef signed char int_least8_t; #endif #endif typedef short int_least16_t; typedef int int_least32_t; #ifdef _LP64 typedef long int_least64_t; #else /* _ILP32 */ #if defined(_LONGLONG_TYPE) typedef long long int_least64_t; #endif #endiftypedef unsigned char uint_least8_t; typedef unsigned short uint_least16_t; typedef unsigned int uint_least32_t; #ifdef _LP64 typedef unsigned long uint_least64_t; #else /* _ILP32 */ #if defined(_LONGLONG_TYPE) typedef unsigned long long uint_least64_t; #endif #endif#ifdef __cplusplus } #endif#endif /* _SYS_INT_TYPES_H */

3.Reference

  • c/c++: uint8_t uint16_t uint32_t uint64_t size_t ssize_t數(shù)據(jù)類型 csdn

總結(jié)

以上是生活随笔為你收集整理的[cpp]c++中的 _t 类的数据类型的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。