unsigned int与UINT32有什么区别?

sweatytoothbuaa 2011-07-18 07:39:54
不太明白
...全文
10863 45 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
45 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2012-01-12
  • 打赏
  • 举报
回复
C:\Program Files\Microsoft Visual Studio\VC98\Include\BASETSD.H
    41: typedef unsigned int UINT32, *PUINT32;
WarriorKing 2012-01-12
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bdmh 的回复:]
一样
typedef unsigned int UINT32
[/Quote]不一样好吧,要看具体是怎么定义的,有些就不一定是你这样定义的
nice_cxf 2012-01-12
  • 打赏
  • 举报
回复
方便移植?gcc里面连UINT32都没有,方便的了才怪
如果微软日后升级了vs,把int升级为64位了,只是方便了这种移植,跨平台大概要用uint_32_t,不过vs似乎目前不支持
hello_kitty8888 2012-01-12
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 z214957578 的回复:]

引用 15 楼 babilife 的回复:
引用 14 楼 luciferisnotsatan 的回复:
UINT32 确保是 无符号32位整形
unsigned int 不一样是32位的


+++1

+++++1
[/Quote]
+++++++++++++++1
ccjsj1 2012-01-12
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 long0530 的回复:]
typedef unsigned int UINT32
UINT32 使用起来更方便,在32位系统上和 unsigned int 是一个意思
[/Quote]

UNIT32通过typedef unsigned int 了,为了跨平台兼容性好。
朱韦刚 2011-08-25
  • 打赏
  • 举报
回复
typedef struct A
{
int a;
}A_p

A_p a_p;
a_p.a = 2;

一样是为了方便!!
mymtom 2011-08-25
  • 打赏
  • 举报
回复
C99标准里有uint_32_t,在stdint.h或inttypes.h里。
CJacky++ 2011-08-25
  • 打赏
  • 举报
回复
嗯,没错,是方便移值。
嵌入式项目里很少直接使用C语言内置数据类型名,因为C标准没有把内置数据类型的大小定死,不方便在不同的平台移植。
ddownload 2011-08-25
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bdmh 的回复:]
一样
typedef unsigned int UINT32
[/Quote]

您又来忽悠人?您这种鸟水平还申请版主?
daviddb7 2011-08-25
  • 打赏
  • 举报
回复
int在不同的环境下可能大小不一样,而UINT32指明了在任何环境下,都是32位的。
如果确定是32位环境,那这两个没有区别。
wyfwx 2011-08-25
  • 打赏
  • 举报
回复
unsigned int是预定好的,
UINT32是要另外定义的,你可以把它定义成任何东西
Chuckbass 2011-08-24
  • 打赏
  • 举报
回复
学习了
自由建客 2011-07-21
  • 打赏
  • 举报
回复
[Quote=引用 28 楼 0153 的回复:]
64位编译器中一般会采用以下定义:
typedef unsigned long UINT32;

typedef unsigned short UINT32;
[/Quote]
typedef unsigned int UINT32;
0153 2011-07-21
  • 打赏
  • 举报
回复
[Quote=引用 27 楼 ljd680 的回复:]

引用 14 楼 luciferisnotsatan 的回复:

UINT32 确保是 无符号32位整形
unsigned int 不一样是32位的


请问一下是如何确保的,如果一个是32位,一个是64位,那么UINT32在64位中如何保证是32为而不是64位呢?
谢谢!
[/Quote]

64位编译器中一般会采用以下定义:
typedef unsigned long UINT32;

typedef unsigned short UINT32;
炼气士 2011-07-21
  • 打赏
  • 举报
回复
[Quote=引用 14 楼 luciferisnotsatan 的回复:]

UINT32 确保是 无符号32位整形
unsigned int 不一样是32位的
[/Quote]

请问一下是如何确保的,如果一个是32位,一个是64位,那么UINT32在64位中如何保证是32为而不是64位呢?
谢谢!
紫色动力 2011-07-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bdmh 的回复:]

一样
typedef unsigned int UINT32
[/Quote]
学习了
ccnadogteam2 2011-07-21
  • 打赏
  • 举报
回复
学习了
picurl 2011-07-21
  • 打赏
  • 举报
回复
1. 確保 32 位
2. 在各機器及各版本 include 中都有對應的宣告
3. 以本人實際工作使用來說,我們透過一交換平台與其他公司交換資料,
因各家使用的機台平台不同,因此,例如 int 所佔的 byte 是不同的,
為交換資料的一致性,在數字規格定義上都用 UINT8, UINT16, UINT32 等等,
確保交換無誤
Dirk 2011-07-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 bdmh 的回复:]
一样
typedef unsigned int UINT32
[/Quote]

书写简短,还有就是便于移植。
pathuang68 2011-07-21
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 sweatytoothbuaa 的回复:]

引用 1 楼 bdmh 的回复:

一样
typedef unsigned int UINT32


那有了unsigned int,为啥又要有UINT32呢?
[/Quote]
方便嘛。UINT32才敲6下,unsigned int要敲次数多一些吧。最主要的还是为了保证数据类型名称上的一致性。
加载更多回复(24)
看到一个不错的c++实现的md5算法 class MD5 { public: typedef unsigned int size_type; // must be 32bit MD5(); MD5(const std::string& text); void update(const unsigned char *buf, size_type length); void update(const char *buf, size_type length); MD5& finalize(); std::string hexdigest() const; friend std::ostream& operator<<(std::ostream&, MD5 md5); private: void init(); typedef unsigned char uint1; // 8bit typedef unsigned int uint4; // 32bit enum {blocksize = 64}; // VC6 won't eat a const static int here void transform(const uint1 block[blocksize]); static void decode(uint4 output[], const uint1 input[], size_type len); static void encode(uint1 output[], const uint4 input[], size_type len); bool finalized; uint1 buffer[blocksize]; // bytes that didn't fit in last 64 byte chunk uint4 count[2]; // 64bit counter for number of bits (lo, hi) uint4 state[4]; // digest so far uint1 digest[16]; // the result // low level logic operations static inline uint4 F(uint4 x, uint4 y, uint4 z); static inline uint4 G(uint4 x, uint4 y, uint4 z); static inline uint4 H(uint4 x, uint4 y, uint4 z); static inline uint4 I(uint4 x, uint4 y, uint4 z); static inline uint4 rotate_left(uint4 x, int n); static inline void FF(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); static inline void GG(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); static inline void HH(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); static inline void II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac); }; std::string md5(const std::string &str);

70,020

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧