OS X:为什么 __LP64__ 会导致纯虚函数?

发布于 2024-11-04 21:04:37 字数 855 浏览 5 评论 0原文

我正在尝试更新一些 2003 年左右的 I/O Kit 代码,我遇到了一些奇怪的事情:有一些地方只有当 __LP64__< /code> 预处理器宏已设置。例如,来自 IOBlockStorageDevice:

public
#ifdef __LP64__
    virtual IOReturn    getWriteCacheState(bool *enabled)   = 0;
#else /* !__LP64__ */
    virtual IOReturn    getWriteCacheState(bool *enabled); /* 10.3.0 */
#endif /* !__LP64__ */

上面的例子中,为什么在>=10.4中强制执行getWriteCacheStatus,而在10.3中不强制执行呢?这只是“我们之前应该这样做”的情况还是有更深层次的东西我没有看到(通常是这种情况)。

I'm attempting to update some circa-2003 I/O Kit code and I'm running to something strange: there are a few places where methods are declared as pure virtual only if the __LP64__ preprocessor macro is set. Example, from IOBlockStorageDevice:

public
#ifdef __LP64__
    virtual IOReturn    getWriteCacheState(bool *enabled)   = 0;
#else /* !__LP64__ */
    virtual IOReturn    getWriteCacheState(bool *enabled); /* 10.3.0 */
#endif /* !__LP64__ */

In the above example, why force the implementation of getWriteCacheStatus in >=10.4 but not in 10.3? Is this just a case of "we should have done this before" or is there something deeper that I'm not seeing (which is usually the case).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千仐 2024-11-11 21:04:37

我的猜测是,32 位版本包含一个默认实现,可用于在引入该方法之前编写的驱动程序。由于从来没有 64 位版本的 OSX 不包含该方法,因此他们不需要提供后备。我在 IOKit 的其他部分看到了类似的模式,用于取代已弃用的方法的新方法。已弃用的方法仅存在于 32 位模式下,并且默认情况下会调用新方法。新方法在64位模式下是纯虚拟的。

My guess is that the 32-bit version includes a default implementation to fall back on for drivers written before the method was introduced. Since there was never a 64-bit version of OSX that didn't include that method, they don't need to provide a fallback. I've seen similar patterns in other parts of IOKit for new methods that supersede deprecated methods. The deprecated method only exists in 32-bit mode and by default calls the new method. The new method is pure virtual in 64-bit mode.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文