首页 > 其他 > 详细

typedef typedef struct的使用

时间:2016-05-16 15:48:16      阅读:211      评论:0      收藏:0      [点我收藏+]

typedef通常情况用于声明结构体之类的

1,定义某些便于记忆的结构体或者使现有的类型看上去更加整齐,比如后来因为经常使用而被添加进入c/c++标准头文件的stdint.h

1 typedef signed char        int8_t;
2 typedef short              int16_t;
3 typedef int                int32_t;
4 typedef long long          int64_t;
5 typedef unsigned char      uint8_t;
6 typedef unsigned short     uint16_t;
7 typedef unsigned int       uint32_t;
8 typedef unsigned long long uint64_t;

uint_8,uint_16,uint_32这样用无符号的数在进行嵌入式或者其他底层的数据处理中有着莫名的整齐干净的感觉。同时如果存在某些虽然是简单地定义,但是为了方便记忆,比如我们需要声明一个32位的文件序号:

1 typedef Uint32 tFileIndex;

这样我们在声明用于记录序号的变量时,tFileIndex findex;就可以实现,而且还能提示我们生命的这个变量的作用。在处理多个同样结构的变量的定义时有着独特的效果。

 

2,好困,后续再补

 

typedef typedef struct的使用

原文:http://www.cnblogs.com/fireyjy/p/5498284.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!