uint128_t没有命名类型 [英] uint128_t does not name a type
问题描述
我正在将一些代码从C转移到C ++。在我遇到的转换过程中:
I am porting some code from C to C++. During the conversion I encountered:
uint128_t
未命名类型
我的编译器:gcc版本5.2.1
我的操作系统:Ubuntu 15.1
My compiler: gcc version 5.2.1
My operating system: Ubuntu 15.1
这个编译的罚款为C,我认为它将通过包含 stdint.h
来解决,但事实并非如此。到目前为止,我还没有尝试过其他任何事情,因为似乎没有关于此错误的大量信息( example )。 uint128_t
在整个程序中使用并且对于构建是必不可少的,因此我无法删除它,并且我不确定使用不同的整数类型。
This compiled fine as C and I thought it would be resolved by including stdint.h
but it has not. So far I have not tried anything else since there doesn't seem to be a lot of information on this error (example). uint128_t
is used throughout this entire program and is essential for the build, therefore I can not remove it, and I'm not sure about using a different integer type.
以下是使用地点和方式的示例。
Below is an example of where and how it is used.
union {
uint16_t u16;
uint32_t u32;
uint128_t u128;
} value;
可以定义 uint128_t
或者我应该查看我的编译器?
Would it be okay to define a uint128_t
or should I look at my compiler?
推荐答案
GCC内置了对类型 __ int128
, unsigned __int128
, __ int128_t
和 __ uint128_t
(最后两个未记录)。使用它们来定义自己的类型:
GCC has builtin support for the types __int128
, unsigned __int128
, __int128_t
and __uint128_t
(the last two are undocumented). Use them to define your own types:
typedef __int128 int128_t;
typedef unsigned __int128 uint128_t;
或者,您可以使用 __ mode __(TI)
:
typedef int int128_t __attribute__((mode(TI)));
typedef unsigned int uint128_t __attribute__((mode(TI)));
引用文档:
TImode
Tetra Integer(?)模式表示一个16字节的整数。
"Tetra Integer" (?) mode represents a sixteen-byte integer.
16个字节= 16 * CHAR_BIT> = 128。
Sixteen byte = 16 * CHAR_BIT >= 128.
这篇关于uint128_t没有命名类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!