Skip to content

'zig cc' and 'clang' behavior differ on Mac OS 10.15.7 #6923

Description

@emidoots

The C code below compiles with clang via:

clang test.c -framework Cocoa -framework Foundation -o test.app

However, with zig cc:

zig cc test.c -framework Cocoa -framework Foundation -o test.app
test.c:6:10: fatal error: 'Carbon/Carbon.h' file not found
#include <Carbon/Carbon.h>
^~~~~~~~~~~~~~~~~
1 error generated.

Is this a bug in Zig, or a misunderstanding I have about how clang on Mac OS handles includes?

#include<objc/runtime.h>#include<objc/message.h>#include<Carbon/Carbon.h>#definecls objc_getClass
#definesel sel_getUid
#definemsg ((id (*)(id, SEL, ...))objc_msgSend)
#definecls_msg ((id (*)(Class, SEL, ...))objc_msgSend)
// poor man's bindings!typedefenumNSApplicationActivationPolicy {
NSApplicationActivationPolicyRegular=0,
NSApplicationActivationPolicyAccessory=1,
NSApplicationActivationPolicyERROR=2,
} NSApplicationActivationPolicy;
typedefenumNSWindowStyleMask {
NSWindowStyleMaskBorderless=0,
NSWindowStyleMaskTitled=1 << 0,
NSWindowStyleMaskClosable=1 << 1,
NSWindowStyleMaskMiniaturizable=1 << 2,
NSWindowStyleMaskResizable=1 << 3,
} NSWindowStyleMask;
typedefenumNSBackingStoreType {
NSBackingStoreBuffered=2,
} NSBackingStoreType;
intmain(intargc, char*argv[])
{
// id app = [NSApplication sharedApplication];idapp=cls_msg(cls("NSApplication"), sel("sharedApplication"));
// [app setActivationPolicy:NSApplicationActivationPolicyRegular];msg(app, sel("setActivationPolicy:"), NSApplicationActivationPolicyRegular);
structCGRectframeRect= {0, 0, 600, 500};
// id window = [[NSWindow alloc] initWithContentRect:frameRect styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO];idwindow=msg(cls_msg(cls("NSWindow"), sel("alloc")),
sel("initWithContentRect:styleMask:backing:defer:"),
frameRect,
NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskResizable,
NSBackingStoreBuffered,
false);
msg(window, sel("setTitle:"), cls_msg(cls("NSString"), sel("stringWithUTF8String:"), "Pure C App"));
// [window makeKeyAndOrderFront:nil];msg(window, sel("makeKeyAndOrderFront:"), nil);
// [app activateIgnoringOtherApps:YES];msg(app, sel("activateIgnoringOtherApps:"), true);
msg(app, sel("run"));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.enhancementSolving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.os-macosmacOS

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions