-
-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Description
Bug description
On macOS, compilation fails when osdp_export.h is included after system headers (e.g., <os/availability.h>), which defines API_DEPRECATED with a variadic signature. The library’s single-argument macro redefinition causes:
error: too many arguments provided to function-like macro invocation
Expected behavior
The header should be safely re-includable without conflicts, regardless of system header order.
Observed behavior
Macro redefinition error on macOS (Clang/Xcode) due to incompatible API_DEPRECATED definitions.
Fix applied
Added #undef API_DEPRECATED before redefining the macro in osdp_export.h, ensuring safe override of any prior definition (e.g., from Apple’s SDK).
/* ---------- Deprecation (with message) ---------- */
/*
* CHANGED: Undefine API_DEPRECATED before redefining it. On macOS the SDK
* header <os/availability.h> defines API_DEPRECATED with a different
* signature (platform/version specifiers, not a plain string), which causes
* macro expansion errors when osdp.h uses OSDP_DEPRECATED_EXPORT("msg").
*/
#undef API_DEPRECATED
/* Prefer C++ [[deprecated("msg")]] if available, otherwise compiler specifics. */
#if defined(__cplusplus) && API_HAS_CPP_ATTR(deprecated)
/* [[deprecated("msg")]] supported */
#define API_DEPRECATED(msg) [[deprecated(msg)]]
#elif defined(_MSC_VER)
/* MSVC supports __declspec(deprecated("msg")) */
#define API_DEPRECATED(msg) __declspec(deprecated(msg))
#elif (defined(__clang__) && API_HAS_ATTR(deprecated)) \
|| (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)))
/* Clang and modern GCC support attribute deprecated("msg") */
#define API_DEPRECATED(msg) __attribute__((deprecated(msg)))
#elif (defined(__GNUC__) || defined(__clang__))
/* Older GCC/Clang: attribute deprecated without message */
#define API_DEPRECATED(msg) __attribute__((deprecated))
#else
/* Unknown compiler: no-op */
#define API_DEPRECATED(msg)
#endif
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels