[英]How does clang's uint24_t work? Can I use it outside clang/LLVM?
Being a GCC user, I've just noticed clang supports a uint24_t
type (it's in their stdint.h
anyway). 作为GCC用户,我刚刚注意到clang支持
uint24_t
类型(无论如何它都在stdint.h
)。
How does that work? 这是如何运作的? I mean, is it supported purely internally, as a language extension, or is it implemented like a C++ class would, with some abstraction over 3 bytes or a 16-bit value and another 8-bit value?
我的意思是,它是纯粹在内部支持,作为语言扩展,还是像C ++类一样实现,有一些抽象超过3个字节或16位值和另一个8位值? And - how possible is it to 'yank' such an implementation and use it myself, with GCC?
并且 - 如何可能“猛拉”这样的实现并自己使用GCC?
Note: 注意:
uint_t<N>
more generally); uint_t<N>
); my alternative is rolling my own. s/uint/int/g;
s/uint/int/g;
if you like in this question. This isn't portable or standard. 这不是便携式或标准型。 It exists only for AVR (which has 24-bit addresses), and GCC has it for that architecture, too (since GCC v4.7).
它仅适用于AVR(具有24位地址), GCC也支持该架构 (自GCC v4.7起)。
If the architecture doesn't support a native 24-bit integer, then it won't be defined. 如果体系结构不支持本机24位整数,则不会定义它。
If you look in Clang's stdint.h
header file , you'll see that the 24-bit integer typedefs are conditionally included only when the internal __INT24_TYPE__
symbol is defined: 如果查看Clang的
stdint.h
头文件 ,只有在定义了内部__INT24_TYPE__
符号时,才会看到有条件地包含24位整数typedef:
#ifdef __INT24_TYPE__
typedef __INT24_TYPE__ int24_t;
typedef __UINT24_TYPE__ uint24_t;
typedef int24_t int_least24_t;
typedef uint24_t uint_least24_t;
typedef int24_t int_fast24_t;
typedef uint24_t uint_fast24_t;
# define __int_least16_t int24_t
# define __uint_least16_t uint24_t
# define __int_least8_t int24_t
# define __uint_least8_t uint24_t
#endif /* __INT24_TYPE__ */
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.