August 30, 2023 [Issue 24123] New: More definitions are needed for ImportC to function on macOS (additions needed for importc.h) | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24123 Issue ID: 24123 Summary: More definitions are needed for ImportC to function on macOS (additions needed for importc.h) Product: D Version: D2 Hardware: x86_64 OS: Mac OS X Status: NEW Severity: blocker Priority: P1 Component: druntime Assignee: nobody@puremagic.com Reporter: trnsz@pobox.com Using DMD ImportC on macOS, most non-trivial programs that use stdio won't function. Using macOS Intel 13.5, Darwin 22.6.0, Xcde 14.3.1, DMD64 v2.105.0. Problem is that https://github.com/dlang/dmd/blob/25d2741b86b1060ec43d80dbcc8dc190d5453322/druntime/src/importc.h#L98 is incomplete. For my application to compile and link, I had to add the following additional lines here in the APPLE section. I'm sure others will likely be needed, but this was enough for me. # define __builtin___snprintf_chk(s, c, flag, os, fmt, ...) snprintf(s, c, fmt, __VA_ARGS__) # define __builtin___sprintf_chk(s, flag, os, fmt, ...) sprintf(s, fmt, __VA_ARGS__) # define __builtin___vsnprintf_chk(s, c, flag, os, fmt, ...) vsnprintf(s, c, fmt, __VA_ARGS__) # define __builtin___strlcat_chk(dest, src, x, n) strlcat(dest,src,x) # define __builtin___strlcpy_chk(dest, src, x, n) strlcpy(dest,src,x) # define __builtin_object_size ---- I hope this is helpful! Perhaps this should be another issue, but, it seems one cannot use C11 atomics. I don't know if this is something that can be worked around, but if you try to use them, you get the following error messages from DMD: file.c(99): Error: undefined identifier `__c11_atomic_load` file.c(126): Error: undefined identifier `__c11_atomic_store` file.c(204): Error: undefined identifier `__c11_atomic_store` file.c(220): Error: undefined identifier `__c11_atomic_load` file.c(429): Error: undefined identifier `__c11_atomic_init` I can work around this for my application, but, as ImportC is supposed to be C11 compliant, I'd hope that C11 atomics can be supported on macOS. -- |
Copyright © 1999-2021 by the D Language Foundation