www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22631] New: ImportC: clang's enums of a specific underlying

https://issues.dlang.org/show_bug.cgi?id=22631

          Issue ID: 22631
           Summary: ImportC: clang's enums of a specific underlying type
                    extension is unsupported
           Product: D
           Version: D2
          Hardware: All
                OS: Mac OS X
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dave287091 gmail.com

Clang has an extension for specifying the underlying type of an enum (in the
same way as c++ 11). See here:
https://clang.llvm.org/docs/LanguageExtensions.html#enumerations-with-a-fixed-underlying-type

Despite what the docs say, it works when compiling C code as well.

An example of where this is used is in <os/clock.h> and other headers in the os
group. After preprocessing, it expands to:

typedef enum : uint32_t { OS_CLOCK_MACH_ABSOLUTE_TIME = 32, } os_clockid_t;

Use of this feature is guarded by `__has_feature(objc_fixed_enum)`, but if you
are using clang as the pre-processor, this will be true and there doesn’t seem
to be any argument to clang or a #define that will make it not true.

--
Dec 27 2021