diff options
| author | kcbanner <kcbanner@gmail.com> | 2023-11-05 00:27:08 -0400 |
|---|---|---|
| committer | kcbanner <kcbanner@gmail.com> | 2023-11-05 20:34:13 -0500 |
| commit | 26dabbf301ce4cd950cd66373dc17f0747c1e813 (patch) | |
| tree | 712d1971bf81fc0dc1bb5aaf3003ef555d658cdd | |
| parent | 192e9a315d92133b27d757f18bd4fd619976b755 (diff) | |
| download | zig-26dabbf301ce4cd950cd66373dc17f0747c1e813.tar.gz zig-26dabbf301ce4cd950cd66373dc17f0747c1e813.zip | |
cbe: handle underscore prexfix on macos, don't mangle extern function names
| -rw-r--r-- | lib/zig.h | 4 | ||||
| -rw-r--r-- | src/codegen/c.zig | 2 |
2 files changed, 5 insertions, 1 deletions
@@ -203,7 +203,11 @@ typedef char bool; __pragma(comment(linker, "/alternatename:_" #symbol "=_" #name )) #endif /*_M_X64 */ #else +#if __APPLE__ +#define zig_import(sig, symbol, name) zig_extern sig __asm("_" #name); +#else /* __APPLE__ */ #define zig_import(sig, symbol, name) zig_extern sig __asm(#name); +#endif /* __APPLE__ */ #endif #define zig_expand_import(sig, symbol, name) zig_import(sig, symbol, name) diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 735b58e2dd..46895d71a7 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -1978,7 +1978,7 @@ pub const DeclGen = struct { if (mod.decl_exports.get(decl_index)) |exports| { try writer.print("{ }", .{fmtIdent(mod.intern_pool.stringToSlice(exports.items[export_index].opts.name))}); } else if (decl.getExternDecl(mod).unwrap()) |extern_decl_index| { - try writer.print("{ }", .{fmtIdent(mod.intern_pool.stringToSlice(mod.declPtr(extern_decl_index).name))}); + try writer.print("{}", .{mod.declPtr(extern_decl_index).name.fmt(&mod.intern_pool)}); } else { // MSVC has a limit of 4095 character token length limit, and fmtIdent can (worst case), // expand to 3x the length of its input, but let's cut it off at a much shorter limit. |
