Reputation: 682
When I try to compile anything which includes CoreFoundation, CoreServices or CoreGraphics, e.g Carbon, I get the following error message.
gcc x.c -framework Carbon
In file included from /usr/include/Availability.h:180:0,
from /usr/local/Cellar/gcc/6.2.0/lib/gcc/6/gcc/x86_64-apple-darwin16.1.0/6.2.0/include-fixed/math.h:46,
from /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:24,
from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:19,
from /System/Library/Frameworks/Carbon.framework/Headers/Carbon.h:20,
from x.c:1:
/System/Library/Frameworks/CoreFoundation.framework/Headers/CFDateFormatter.h:53:34: error: 'introduced' undeclared here (not in a function)
kCFISO8601DateFormatWithYear API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0)) = (1UL << 0),
^
/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:777:39: error: 'deprecated' undeclared here (not in a function)
const CFStringRef kCFURLLabelColorKey API_DEPRECATED("Use NSURLLabelColorKey", macosx(10.6, 10.12), ios(4.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0));
^
/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:777:39: error: 'message' undeclared here (not in a function)
const CFStringRef kCFURLLabelColorKey API_DEPRECATED("Use NSURLLabelColorKey", macosx(10.6, 10.12), ios(4.0, 10.0), watchos(2.0, 3.0), tvos(9.0, 10.0));
^
In file included from /System/Library/Frameworks/Security.framework/Headers/Security.h:81:0,
from /System/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers/CSIdentity.h:43,
from /System/Library/Frameworks/CoreServices.framework/Frameworks/OSServices.framework/Headers/OSServices.h:27,
from /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/IconsCore.h:23,
from /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LaunchServices.h:22,
from /System/Library/Frameworks/CoreServices.framework/Headers/CoreServices.h:39,
from /System/Library/Frameworks/Carbon.framework/Headers/Carbon.h:20,
from x.c:1:
/System/Library/Frameworks/Security.framework/Headers/Authorization.h:194:7: error: variably modified 'bytes' at file scope
char bytes[kAuthorizationExternalFormLength];
^~~~~
In file included from /System/Library/Frameworks/CoreGraphics.framework/Headers/CGContext.h:18:0,
from /System/Library/Frameworks/CoreGraphics.framework/Headers/CGBitmapContext.h:9,
from /System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h:11,
from /System/Library/Frameworks/ApplicationServices.framework/Headers/ApplicationServices.h:35,
from /System/Library/Frameworks/Carbon.framework/Headers/Carbon.h:24,
from x.c:1:
/System/Library/Frameworks/CoreGraphics.framework/Headers/CGFont.h:53:40: error: initializer element is not constant
static const CGFontIndex kCGGlyphMax = kCGFontIndexMax;
Does anyone have an idea what the problem might be? I am not sure if this started after updating to macOS Sierra or Xcode to version 8.1. Edit: The program seems to compile in Xcode, but not in terminal with homebrew gcc 6.2.
Upvotes: 4
Views: 2230
Reputation: 575
/System/Library/Frameworks/CoreFoundation.framework/Headers/CFDateFormatter.h:53:34: error: 'introduced' undeclared here (not in a function)
kCFISO8601DateFormatWithYear API_AVAILABLE(macosx(10.12), ios(10.0), watchos(3.0), tvos(10.0)) = (1UL << 0),
IMHO it's just that this header is not supported by gcc-6.2 but only by clang. Maybe it will be "fixed" with gcc-7.
A similar problem exists with gcc-5.x and El Capitan (sdk 10.11) where gcc-6.x is needed in order to build with the Apple headers like this one.
Upvotes: 1
Reputation: 5903
As stated here, Carbon has long been deprecated. However, you might try AppKit:
gcc x.c -framework AppKit
For me it works fine when I write pure-C apps for OS X.
[EDIT:] Now the code.
#include <ApplicationServices/ApplicationServices.h>
#include <unistd.h>
int main() {
while (!CGEventSourceKeyState(kCGEventSourceStateHIDSystemState, 0x7E))
usleep(10000);
return 0;
}
This app only depends on AppKit and loops until up arrow (scan code 0x7E
) is pressed.
Here`s the full list of codes (not sure where they are in official headers): Carbon's Virtual Key Codes.
Upvotes: 2
Reputation: 89509
You tagged this with "Core-Foundation" but the availability macros you're talking about (described more in detail in the first couple paragraphs of the Foundation Release Notes for macOS 10.12 & iOS 10 describe the API Availability Macros a bit more in detail.
I suspect you might need to simply include the Foundation framework in your build (to pick up these macros which CoreFoundation & CoreGraphics appear to depend on) and you should be okay going forward.
Upvotes: 0