为什么`#import <HIToolbox/Events.h>` 会失败? [英] Why does `#import &lt;HIToolbox/Events.h&gt;` fail?

查看:30
本文介绍了为什么`#import <HIToolbox/Events.h>` 会失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 HIToolbox/Events.h 中的 kVK_Space:

#import <Carbon/Carbon.h>

有效,并且此文件包含:

works, and this file contains:

#include <HIToolbox/HIToolbox.h>

但是如果我直接尝试第二个 #include,它会失败.

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

谁能解释一下为什么?

推荐答案

Carbon 是一个 伞形框架".它封装了其他框架,例如HIToolbox.按照设计,为了隐藏实现细节,您不能直接包含子框架的标头.

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.

来自上面的链接:

[T] 两个因素将伞形框架与其他框架区分开来.首先是它们包含头文件的方式.

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

与标准框架不同,伞式框架的 Headers 目录包含一组更有限的头文件.它在其子框架中不包含头文件的集合.相反,它只包含框架的主头文件.在源文件中引用伞形框架时,应仅包含主头文件.请参阅 包括框架 了解更多信息.

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.

来自最后一个链接:

[I]如果您要包含一个伞形框架,则必须包含主头文件.Umbrella 框架不允许您直接包含其组成子框架的标头.

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

这篇关于为什么`#import <HIToolbox/Events.h>` 会失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆