我如何将 C/C99 规范与 C++ 进行比较规格?
我需要验证我是否可以以某种方式使用联合体。
对于 C99,这个答案就足够了:联合元素对齐
C99 - 第 6.7.2.1 节结构和 union 说明符(第 14 段):
适当地,指向联合对象的指针 转换后,指向其每个 成员(或者如果成员是位字段, 然后到其所在单位), 反之亦然。
有人可以帮我找到 C++ 的等效保证吗?
更一般地说,是否有一个好的来源可以查找与 C 中已知功能等效的 C++ 标准的章节/段落引用?
多谢。
I need to verify that I can use unions a certain way.
For C99, this answer is adequate: Union element alignment
C99 - section 6.7.2.1 Structure and
union specifiers (paragraph 14):A pointer to a union object, suitably
converted, points to each of its
members (or if a member is a bitfield,
then to the unit in which it resides),
and vice versa.
Can someone please help me find the equivalent guarantee for C++?
More generally, is there a good source for finding section/paragraph citations for C++ standards which are equivalent to a known feature in C?
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 C++ (14882:2003) 中,这分为两个段落:
9.5[class.union]/1
9.2[class.mem]/17
我还没有听说过 C 和 C++ 之间有这样的交叉引用,它可能很重要,如本例所示。
In C++ (14882:2003), this is split between two paragraphs:
9.5[class.union]/1
9.2[class.mem]/17
I haven't heard of a cross-reference between C and C++ like that, it may be non-trivial, as this example shows.
仅供参考,如果您想检查 C++ 标准,不幸的是它不是免费的。您必须付费才能获得该标准的副本。不过,最终草案(批准前的草案)可在线获取:对于 C++99 http ://www.kuzbass.ru:8086/docs/isocpp/,对于 C++0x http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3092.pdf。
FYI, if you want to check the C++ standard, unfortunately it is not available for free. You must pay a fee to get a copy of the standard. However, the final draft (the one before the approval) is available online: for C++99 http://www.kuzbass.ru:8086/docs/isocpp/, for C++0x http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3092.pdf.