From b902381221067fc99ee5b090dfcba427484f87f0 Mon Sep 17 00:00:00 2001 From: Eric Jiang Date: Fri, 2 Dec 2022 21:50:04 -0800 Subject: [PATCH] Define alias for le16toh on macOS Fixes #25 --- usbscale.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/usbscale.c b/usbscale.c index 56d6540..ef69429 100644 --- a/usbscale.c +++ b/usbscale.c @@ -53,6 +53,13 @@ along with this program. If not, see . #define WEIGH_REPORT_SIZE 6 #define CONTROL_REPORT_SIZE 2 +// `le16toh` is not available on MacOS (as of 12.6) but we can replace it with +// a similar function. +#if defined(__APPLE__) + #include + #define le16toh(x) OSSwapLittleToHostInt16(x) +#endif + // // **find_scale** takes a libusb device list and finds the first USB device // that matches a device listed in scales.h.