www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24123] New: More definitions are needed for ImportC to

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.


__VA_ARGS__)

__VA_ARGS__)

fmt, __VA_ARGS__)




----

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.

--
Aug 30 2023