opencv()——uint8_t / uint16_t / uint32_t /uint64_t 是什么数据类型、

它就是一个结构的标注,可以理解为type/typedef的缩写,表示它是通过typedef定义的,而不是其它数据类型。

uint8_t,uint16_t,uint32_t等都不是什么新的数据类型,它们只是使用typedef给类型起的别名,新瓶装老酒的把戏。不过,不要小看了typedef,它对于你代码的维护会有很好的作用。比如C中没有bool,于是在一个软件中,一些程序员使用int,一些程序员使用short,会比较混乱,最好就是用一个typedef来定义,如:
typedef char bool;

一般来说,一个C的工程中一定要做一些这方面的工作,因为你会涉及到跨平台,不同的平台会有不同的字长,所以利用预编译和typedef可以让你最有效的维护你的代码。为了用户的方便,C99标准的C语言硬件为我们定义了这些类型,我们放心使用就可以了。

按照posix标准,一般整形对应的*_t类型为:
1字节     uint8_t
2字节     uint16_t
4字节     uint32_t
8字节     uint64_t

附:C99标准中inttypes.h的内容

 /*
    inttypes.h
 
    Contributors:
    Createdby Marek Michalkiewicz <marekm@linux.org.pl>
 
    THISSOFTWARE IS NOT COPYRIGHTED
 
    Thissource code is offered for use in the public domain.  You may
    use,modify or distribute it freely.
 
    Thiscode is distributed in the hope that it will be useful, but
    WITHOUTANY WARRANTY.  ALLWARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
    DISCLAIMED.  This includes but is not limited towarranties of
   MERCHANTABILITYor FITNESS FOR A PARTICULAR PURPOSE.
*/
 
 #ifndef __INTTYPES_H_
 #define __INTTYPES_H_

 /* Use [u]intN_t if you need exactly N bits.
    XXX- doesn't handle the -mint8 option.  */
 
 typedefsigned char int8_t;
 typedefunsigned char uint8_t;
 
 typedefint int16_t;
 typedefunsigned int uint16_t;
 typedeflong int32_t;

 typedefunsigned long uint32_t;

 typedeflong long int64_t;
 typedefunsigned long long uint64_t;

 typedefint16_t intptr_t;
 typedefuint16_t uintptr_t;
 
 #endif

转自:http://www.cnblogs.com/baochun968/archive/2011/10/19/2218008.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值