epoll_data_t问题(特别是关于C数据类型)
联合 epoll_data_t
看起来像:
typedef union epoll_data {
void *ptr;
int fd;
__uint32_t u32;
__uint64_t u64;
} epoll_data_t;
这更像是一个一般的 C 问题,但是为什么使用前导双下划线 __uint{32,64} 类型,而不是只使用不带下划线的 uint{32,64} 类型?我真的不明白为什么/何时使用下划线版本,但我认为不带下划线的 uint32 是在可向外界公开修改的联合中使用的正确选择。
The union epoll_data_t
looks like:
typedef union epoll_data {
void *ptr;
int fd;
__uint32_t u32;
__uint64_t u64;
} epoll_data_t;
This is more of a general C question, but why are the leading double underscores __uint{32,64} types used instead of just uint{32,64} without the underscores? I don't really understand why/when you would use the underscore version, but I thought that uint32 without underscores would be the proper thing to use in a union publicly modifiable to the outside world.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
前导下划线保留给编译器/库供应商,以避免在全局命名空间中创建与客户创建的符号发生冲突的符号。不幸的是,客户也一直将其用于自己的“系统级”声明,第三方库供应商也是如此,迫使供应商开始使用两个下划线。带有 3 个下划线的符号已在野外被发现,但尚未广泛传播。
A leading underscore is reserved to the compiler/library vendor to avoid creating symbols in the global namespace that collide with symbols created by their customers. Unfortunately, customers have been using this too for their own "system level" declarations, as do 3rd party library vendors, forcing the vendors to start using two underscores. Symbols with 3 underscores have been found in the wild but are not yet wide-spread.
固定宽度整数类型已通过 C99 标准化。在此之前,编译器和库作者引入了他们自己的类型,这些可能是其中的残余;据我所知,MS 仍然没有随 Visul Studio 一起提供
stdint.h
。Fixed-width integer types were standardized with C99. Before that, compiler and library authors introduced their own types, of which these might be a remnant; afaik MS still doesn't ship
stdint.h
with Visul Studio.直接来自维基百科 [http://en.wikipedia.org/wiki/Underscore]
Directly from wikipedia [http://en.wikipedia.org/wiki/Underscore]