[MacPorts] #64597: libusb @ 1.0.25: error: use of undeclared identifier 'CLOCK_MONOTONIC'; error: 'TARGET_OS_OSX' is not defined, evaluates to 0; 'clock_gettime' is invalid in C99

MacPorts noreply at macports.org
Thu Feb 3 10:22:58 UTC 2022


#64597: libusb @ 1.0.25: error: use of undeclared identifier 'CLOCK_MONOTONIC';
error: 'TARGET_OS_OSX' is not defined, evaluates to 0; 'clock_gettime' is
invalid in C99
-----------------------+---------------------------------
  Reporter:  thetrial  |      Owner:  michaelld
      Type:  defect    |     Status:  assigned
  Priority:  Normal    |  Milestone:
 Component:  ports     |    Version:  2.7.1
Resolution:            |   Keywords:  elcapitan legacy-os
      Port:  libusb    |
-----------------------+---------------------------------

Comment (by ryandesign):

 Replying to [ticket:64597 thetrial]:
 > {{{
 > :info:build os/darwin_usb.c:1804:3: error: implicit declaration of
 function 'clock_gettime' is invalid in C99 [-Werror,-Wimplicit-function-
 declaration]
 > :info:build   clock_gettime(CLOCK_MONOTONIC, &start);
 > :info:build   ^
 > }}}

 `clock_gettime` and `CLOCK_MONOTONIC` are new as of macOS 10.12. If libusb
 requires them, and if the developers will not provide compatibility
 implementations for older systems that do not have them, then the port can
 include the legacysupport portgroup to use our implementations of them.
 (The portfile already includes legacysupport conditionally in the libusb-
 devel subport.)

 > {{{
 > :info:build os/darwin_usb.c:2420:5: error: 'TARGET_OS_OSX' is not
 defined, evaluates to 0 [-Werror,-Wundef]
 > :info:build #if TARGET_OS_OSX
 > :info:build     ^
 > }}}

 We recently switched MacPorts to use a newer clang compiler on older
 systems. This newer clang happens to introduce this new error. When I've
 encountered this error before, the correct fix was for that source file to
 `#include <TargetConditionals.h>` (which is where the `TARGET_OS_*`
 constants get defined).

-- 
Ticket URL: <https://trac.macports.org/ticket/64597#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list