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).

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top