Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

enter image description here

#import <Carbon/Carbon.h>

works, and this file contains:

#include <HIToolbox/HIToolbox.h>

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

enter image description here

Can anyone explain why?

like image 470
P i Avatar asked May 15 '26 21:05

P i


1 Answers

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.

like image 158
Ken Thomases Avatar answered May 19 '26 03:05

Ken Thomases



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!