Why does `#import <HIToolbox/Events.h>` fail?

为君一笑 提交于 2019-12-11 06:47:56

问题


I require kVK_Space which is in HIToolbox/Events.h:

#import <Carbon/Carbon.h>

works, and this file contains:

#include <HIToolbox/HIToolbox.h>

But if I try this second #include directly, it fails.

Can anyone explain why?


回答1:


Carbon is an "umbrella framework". It encapsulates other frameworks, such as HIToolbox. By design, to hide the implementation details, you can't directly include the headers of the subframeworks.

From the above link:

[T]wo factors distinguish umbrella frameworks from other frameworks. The first is the manner in which they include header files.

Unlike standard frameworks, the Headers directory of an umbrella framework contains a more limited set of header files. It does not contain a collection of the headers in its subframeworks. Instead, it contains only the master header file for the framework. When referring to an umbrella framework in your source files, you should include only the master header file. See Including Frameworks for more information.

From that last link:

[I]f you are including an umbrella framework, you must include the master header file. Umbrella frameworks do not allow you to include the headers of their constituent subframeworks directly.



来源:https://stackoverflow.com/questions/56925840/why-does-import-hitoolbox-events-h-fail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!