From 9e36b8f29cf9e937ca78dda816e1962addfdb7e8 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Mon, 24 Apr 2017 22:09:33 +0000 Subject: [PATCH] usb: improve c++ compatiblity Extract the definition of the usb_interface internal data to allow easier integration with c++ code. Fixes: https://github.com/libopencm3/libopencm3/issues/762 --- include/libopencm3/usb/usbstd.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/include/libopencm3/usb/usbstd.h b/include/libopencm3/usb/usbstd.h index ec5881ae..78abf247 100644 --- a/include/libopencm3/usb/usbstd.h +++ b/include/libopencm3/usb/usbstd.h @@ -153,6 +153,16 @@ struct usb_device_qualifier_descriptor { uint8_t bReserved; } __attribute__((packed)); +/* This is only defined as a top level named struct to improve c++ + * compatibility. You should never need to instance this struct + * in user code! */ +struct usb_interface { + uint8_t *cur_altsetting; + uint8_t num_altsetting; + const struct usb_iface_assoc_descriptor *iface_assoc; + const struct usb_interface_descriptor *altsetting; +}; + /* USB Standard Configuration Descriptor - Table 9-10 */ struct usb_config_descriptor { uint8_t bLength; @@ -165,12 +175,7 @@ struct usb_config_descriptor { uint8_t bMaxPower; /* Descriptor ends here. The following are used internally: */ - const struct usb_interface { - uint8_t *cur_altsetting; - uint8_t num_altsetting; - const struct usb_iface_assoc_descriptor *iface_assoc; - const struct usb_interface_descriptor *altsetting; - } *interface; + const struct usb_interface *interface; } __attribute__((packed)); #define USB_DT_CONFIGURATION_SIZE 9