是否有一种可移植的方法来标记 1 字节对齐指针?
我想创建 2 个具有 1 字节对齐的指针的并集,但我不想存储额外的标记来区分它们。我知道在某些平台上,至少指针的最高有效位未被使用,但将来可能会改变。
请问有人知道一种便携式方法吗?
我希望有一种不会使原始指针无效的技术。也就是说,是否有一个函数,当我将它应用于某个数字 n 时,会释放该数字中的至少一位,而当我“取消应用”它时,会返回原始数字。
I want to create a union of 2 pointers which have 1 byte alignment, but I don't want to store an additional tag, to distinguish them. I know that on some platforms, at least the most significant bit of a pointer is unused, but that might change in the future.
Please does someone know a portable way to do this?
I'm hoping for a technique that does not invalidate the original pointer. That is, is there a function for which when I apply it to some number n, frees up at least one bit in the number and when I "unapply" it, gives me back the original number.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论