bmon icon indicating copy to clipboard operation
bmon copied to clipboard

`__unused__` macro causes naming conflict with Xcode 12

Open mitchblank opened this issue 4 years ago • 0 comments

  CC       bmon-utils.o
In file included from utils.c:31:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/clock.h:13:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/mig_errors.h:113:34: error: use of undeclared identifier 'unused'
__NDR_convert__mig_reply_error_t(__unused mig_reply_error_t *x)
                                 ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:161:40: note: expanded from macro '__unused'
#define __unused        __attribute__((__unused__))
                                       ^
../include/bmon/bmon.h:63:36: note: expanded from macro '__unused__'
#define __unused__ __attribute__ ((unused))
                                   ^

Looking in bmon.h:

#if defined __GNUC__
#define __init __attribute__ ((constructor))
#define __exit __attribute__ ((destructor))
#define __unused__ __attribute__ ((unused))
#else
#define __init
#define __exit
#define __unused__
#endif

Probably those macros should be renamed to something like ATTRIBUTE_UNUSED etc or something. Identifiers with double underscores are reserved for the compiler and system headers so you're always at risk of a clash if you use them yourself: https://stackoverflow.com/a/228797

mitchblank avatar Dec 13 '20 15:12 mitchblank