[Issue 22666] New: ImportC: Error: attributes should be specified before the function definition

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 12 05:48:45 UTC 2022


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

          Issue ID: 22666
           Summary: ImportC: Error: attributes should be specified before
                    the function definition
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dave287091 at gmail.com

The system framework CoreFoundation on macOS has a header file that declares
the following function:

typedef unsigned long CFOptionFlags;
typedef signed long CFIndex;

static inline __attribute__((always_inline)) 
CFOptionFlags CFUserNotificationCheckBoxChecked(CFIndex i)
__attribute__((availability(macos,introduced=10.0)))
__attribute__((availability(ios,unavailable)))
__attribute__((availability(watchos,unavailable)))
__attribute__((availability(tvos,unavailable))) 
{
    return ((CFOptionFlags)(1UL << (8 + i)));
}

It fails with the following error message:

Error: attributes should be specified before the function
 definition

Apparently clang allows attributes in this position (after the parameter list),
but gcc does not.

--


More information about the Digitalmars-d-bugs mailing list