Description
Since 76d05d4 and #15554, Protobuf tries to always use CLOCK_UPTIME_RAW
if compiled for an __APPLE__
system:
protobuf/src/google/protobuf/map.h
Lines 710 to 715 in 9c0d130
But that symbol isn't always defined. On my machine, the MacOSX 14.2 SDK time.h
only defines it if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
evaluates to true:
#if !defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)
_CLOCK_MONOTONIC_RAW __CLOCK_AVAILABILITY = 4,
#define CLOCK_MONOTONIC_RAW _CLOCK_MONOTONIC_RAW
_CLOCK_MONOTONIC_RAW_APPROX __CLOCK_AVAILABILITY = 5,
#define CLOCK_MONOTONIC_RAW_APPROX _CLOCK_MONOTONIC_RAW_APPROX
_CLOCK_UPTIME_RAW __CLOCK_AVAILABILITY = 8,
#define CLOCK_UPTIME_RAW _CLOCK_UPTIME_RAW
_CLOCK_UPTIME_RAW_APPROX __CLOCK_AVAILABILITY = 9,
#define CLOCK_UPTIME_RAW_APPROX _CLOCK_UPTIME_RAW_APPROX
#endif
And Protobuf doesn't seem to define the appropriate macros to enable non-POSIX Darwin features before it includes time.h
:
protobuf/src/google/protobuf/map.h
Lines 28 to 30 in 9c0d130
This leads to a build failure in my project, which defines _POSIX_C_SOURCE
to get Posix 2008 features, but does not define _DARWIN_C_SOURCE
because it does not directly use Darwin extensions.
/usr/local/Cellar/protobuf/25.3/include/google/protobuf/map.h:694:31: error: use of undeclared identifier 'CLOCK_UPTIME_RAW'
s = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
^
Protobuf should either set the right macros for the features it needs itself, or else document the macros that user code must (or must not) define to build against Protobuf. Or, Protobuf should check the defined macros and use only features that will be available.
Activity