macOS: system header confusion when compiling C code (current Zig 0.8.0 head) #8360
Labels
arch-x86_64
64-bit x86
bug
Observed behavior contradicts documented or intended behavior
os-macos
zig cc
Zig as a drop-in C compiler feature
Milestone
Update 31-Mar-2021: I have renamed the repro-branch to zig-0.8.0-issue8360, and I've added a workaround to my C headers to make it work regardless by not including the problematic macOS system header, but instead embedding the required declarations in the sokol_audio.h header, not great not terrible - I think the underlying problem should still be investigated and fixed - the "workaround version" is in branch "zig-0.8.0").
Target: x86_64-apple-darwin20.4.0
Error terminal output attachment: error.txt
To reproduce:
On macOS:
Description
This is a followup to #7697 (@mikdusan, @kubkon)
I'm now in the process of preparing the sokol-zig bindings for zig 0.8.0, and in general the fixes in this comment (#7697 (comment)) work very well (thanks!) with one exception:
One of the sokol C headers is including the macOS framework header AudioToolbox.h, during the C compilation step an error occurs which seems to be some sort of confusion between the header
x86_64-macos-gnu/os/workgroup.h
that's coming with Zig, and the actual macOS system headers which include this workgroup.h header:Here's the first relevant snippet of the error:
...and further down below:
The 'verbose' command is:
(the entire output is also attached to the ticket, see attachment link at the start of the ticket).
Any ideas what's going wrong here? It seems to me that the C runtime headers which are bundled with Zig are somehow confused by being included from macOS framework headers. It's also interesting to note that this is only happening in one case with the AudioToolbox framework headers.
If you out-comment the sokol_audio.c file in build.zig here:
https://github.com/floooh/sokol-zig/blob/72c8cb0745cf10414b6a331733a9e57b63a17d7b/build.zig#L15
...the C compilation step works, even though the other headers also include plenty of Mac frameworks (most notable all of Cocoa, Metal and MetalKit).
The compilation also used to work in Zig 0.7.1 with the various "system headers hacks" here (this is the main branch that's still on 0.7.1):
https://github.com/floooh/sokol-zig/blob/b058340b38a376b7af3581b4b5306059b3b817e2/build.zig#L6-L12
Ok, I guess that's all the info I have.
Cheers :)
The text was updated successfully, but these errors were encountered: