<dispatch/dispatch.h> on macOS, which is included by <CoreFoundation/CoreFoundation.h>, has an inline function which has a macro defined: #define dispatch_compiler_barrier() __asm__ __volatile__("" ::: "memory”) Where it is used, it is expanded to: typedef void (*dispatch_function_t)(void *); typedef intptr_t dispatch_once_t; extern void dispatch_once_f(dispatch_once_t *predicate, void * context, dispatch_function_t function); static inline /* several attributes omitted */ void _dispatch_once_f(dispatch_once_t *predicate, void * context, dispatch_function_t function) { if (__builtin_expect((*predicate), (~0l)) != ~0l) { dispatch_once_f(predicate, context, function); } else { asm volatile("" ::: "memory"); } __builtin_assume(*predicate == ~0l); } gcc docs on the use of volatile with asm: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile
It does more than not accept the `volatile`, it also does not accept the `( ... )` construct. I'm not sure what to do about it. There are no plans to implement the gnu assembler syntax.
(In reply to Walter Bright from comment #1) > It does more than not accept the `volatile`, it also does not accept the `( > ... )` construct. I'm not sure what to do about it. There are no plans to > implement the gnu assembler syntax. It’s unfortunate as it is not even using the asm, it’s just to inhibit compiler optimizations. If __GNUC__ is not defined it defines it as do { } while(0).
> If __GNUC__ is not defined it defines it as do { } while(0) __GNUC__ is for compiling with gcc. It's not a good idea for ImportC to pretend to be gcc.
(In reply to Walter Bright from comment #3) > > If __GNUC__ is not defined it defines it as do { } while(0) > > __GNUC__ is for compiling with gcc. It's not a good idea for ImportC to > pretend to be gcc. clang also defines __GNUC__. There are other ways extensions like gnu asm can make it into headers, like `#if __has_extension(gnu_asm)`
@ibuclaw created dlang/dmd pull request #14890 "partial fix Issue 22722 - ImportC: parser doesn’t understand 'asm volatile' syntax" mentioning this issue: - partial fix Issue 22722 - ImportC: parser doesn’t understand 'asm volatile' syntax https://github.com/dlang/dmd/pull/14890
dlang/dmd pull request #14890 "partial fix Issue 22722 - ImportC: parser doesn’t understand 'asm volatile' syntax" was merged into master: - a7af3a05452ac5ad8c70996f1eae18f196228b9c by Iain Buclaw: partial fix Issue 22722 - ImportC: parser doesn’t understand 'asm volatile' syntax https://github.com/dlang/dmd/pull/14890
This bug was resolved by https://github.com/dlang/dmd/pull/15011