Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#64597 closed defect (fixed)

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

Reported by: thetrial (alabay) Owned by: michaelld (Michael Dickens)
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: elcapitan legacy-os Cc:
Port: libusb

Description

Something goes wrong. Happened on two machines with El Capitan.

: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   ^
:info:build os/darwin_usb.c:1804:3: note: did you mean 'clock_get_time'?
:info:build /usr/include/mach/clock.h:52:15: note: 'clock_get_time' declared here
:info:build kern_return_t clock_get_time
:info:build               ^
:info:build os/darwin_usb.c:1804:17: error: use of undeclared identifier 'CLOCK_MONOTONIC'
:info:build   clock_gettime(CLOCK_MONOTONIC, &start);
:info:build                 ^
:info:build os/darwin_usb.c:1811:19: error: use of undeclared identifier 'CLOCK_MONOTONIC'
:info:build     clock_gettime(CLOCK_MONOTONIC, &now);
:info:build                   ^
: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     ^
:info:build 4 errors generated.

Attachments (2)

main.log (36.2 KB) - added by thetrial (alabay) 3 years ago.
main.2.log (34.7 KB) - added by RobK88 3 years ago.
main.log created on Lion

Download all attachments as: .zip

Change History (7)

Changed 3 years ago by thetrial (alabay)

Attachment: main.log added

comment:1 in reply to:  description Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to 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).

comment:2 Changed 3 years ago by RobK88

FYI -- I am also unable to build libusb @ 1.0.25 on Lion. Use of undeclared identifier 'CLOCK_MONOTONIC'. But I do NOT see the other error -- "error: 'TARGET_OS_OSX' is not defined".

See attached main.log

Last edited 3 years ago by RobK88 (previous) (diff)

Changed 3 years ago by RobK88

Attachment: main.2.log added

main.log created on Lion

comment:3 Changed 3 years ago by kencu (Ken)

already fixed by using legacysupport

[e342fc5e7afbf63654b308cd816ab120a8c018ad/macports-ports]

sync your ports and give it another try pls

Last edited 3 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:4 Changed 3 years ago by RobK88

Thanks Ken! I am now able to build and install libusb @ 1.0.25 on Lion.

comment:5 Changed 3 years ago by michaelld (Michael Dickens)

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.