2014-03-06 66 views
-5

uint8可以表示为ubyte,uint16可以表示为uword,uint32可以表示为ulong,uint64可以表示为?c中的无符号整数的类型是什么?

我正在寻找无符号整数如何表示为c中的数据类型,但我对如何呈现uint64有困惑? 是否可以使用uint64作为udouble在c中?请有人指导我? 它会支持吗?

什么可能是格式说明符的所有上述?

我只是简单地加入这一行,因为它要求身体不符合要求并告诉添加一些内容。所以我加了这个。

+5

如果您使用的是C99编译器兼容,只是'#包括'你有一个定义上面提到的所有整数类型:'uint8_t','uint16_t','uint32_t','uint64_t'和签名的对应。 –

+0

什么可能是typedef unsigned long uint32的格式说明符? – user3383557

+2

'#include '然后使用''%'PRIu32'。 – Simple

回答

3

所有这些类型的UINT8,UINT16,UINT32,UINT64不是标准的基本类型和它们或typedef名称或实现定义的类型

至于UINT64然后例如它可以被定义为

typedef unsigned long long uint64; 

考虑到整体类型的大小是实现定义的。所以可能在上面的定义中使用unsigned long就足够了,因为在某些平台上sizeof(unsigned long)可以等于8个字节。

如果你想使用标准的整数类型不依赖于所使用的平台,那么你应该包括头<cstdint>

还有其他定义的类型

typedef unsigned integer type uint8_t; // optional 
typedef unsigned integer type uint16_t; // optional 
typedef unsigned integer type uint32_t; // optional 
typedef unsigned integer type uint64_t; // optional 

typedef unsigned integer type uint_fast8_t; 
typedef unsigned integer type uint_fast16_t; 
typedef unsigned integer type uint_fast32_t; 
typedef unsigned integer type uint_fast64_t; 

typedef unsigned integer type uint_least8_t; 
typedef unsigned integer type uint_least16_t; 
typedef unsigned integer type uint_least32_t; 
typedef unsigned integer type uint_least64_t; 
2
#include <stdint.h> 

中,下述的无符号类型定义获取全局名称空间中定义的所有类型。

#include <cstdint> 

让它在命名空间std中定义。

在我的实现,即在stdint.h我可以找到:

#if __WORDSIZE == 64 
typedef unsigned long int uint64_t; 
#else 
__extension__ 
typedef unsigned long long int uint64_t; 
#endif 

uint32_t

#ifndef __uint32_t_defined 
typedef unsigned int  uint32_t; 
# define __uint32_t_defined 
#endif 
+0

什么可能是typedef unsigned long uint32的格式说明符? – user3383557

+0

@ user3383557 typedef unsigned int uint32_t; – 4pie0