[MacPorts] #61868: libusb @1.0.24: cannot parse USB.h with mainline gcc versions due to variant pragma handling not accepted by gcc
MacPorts
noreply at macports.org
Sat Dec 26 19:40:36 UTC 2020
#61868: libusb @1.0.24: cannot parse USB.h with mainline gcc versions due to
variant pragma handling not accepted by gcc
-----------------------------------+-----------------------
Reporter: dgonyier | Owner: michaelld
Type: defect | Status: reopened
Priority: Normal | Milestone:
Component: ports | Version: 2.6.4
Resolution: | Keywords:
Port: libusb, libusb-devel |
-----------------------------------+-----------------------
Comment (by michaelld):
OK so the build issue is these 2 lines:
https://github.com/libusb/libusb/blob/master/libusb/os/darwin_usb.c#L2150-L2151
{{{
const unsigned char max_transfer_type =
LIBUSB_TRANSFER_TYPE_BULK_STREAM;
const char *transfer_types[max_transfer_type + 1] = {"control", "isoc",
"bulk", "interrupt", "bulk-stream"};
}}}
`LIBUSB_TRANSFER_TYPE_BULK_STREAM` is part of an `enum`
https://github.com/libusb/libusb/blob/master/libusb/libusb.h#L1098-L1113 ,
and -could- thus be taken as a constant by the compiler. Clang indeed does
this, but GCC at least through version 7 doesn't! The error could be more
obvious, too ... took some sleuthing to figure out that the compiler was
referring to the value `max_transfer_type` as being not taken as a
constant. Luckily this issue is easily worked around via changing the 2nd
line to:
{{{
const char *transfer_types[] = {"control", "isoc", "bulk", "interrupt",
"bulk-stream", 0};
}}}
Either way should work, and the code makes sense either way. I just pushed
a patch to use this latter method since it is "more correct" IMHO.
--
Ticket URL: <https://trac.macports.org/ticket/61868#comment:17>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list