AnsweredAssumed Answered

[CubeMX feature request]Prevent warning when using custom USB String descriptors

Question asked by marton.miklos on Sep 15, 2017

If I setup custom string USB string descriptors in the CDC Middleware configuration...

 

..these strings will be generated to the usbd_desc.c file in the following format:

 

/** @defgroup USBD_DESC_Private_Defines
  * @{
  */

#define USBD_VID     1155
#define USBD_LANGID_STRING     1033
#define USBD_MANUFACTURER_STRING     "Digitroll Ltd."
#define USBD_PID_FS     22336
#define USBD_PRODUCT_STRING_FS     "XLiNE-USB Converter"
#define USBD_SERIALNUMBER_STRING_FS     "00000000001A"
#define USBD_CONFIGURATION_STRING_FS     "CDC Config"
#define USBD_INTERFACE_STRING_FS     "CDC Interface"

 

When compiling this code with gcc I got the following warnings:

 

pointer targets in passing argument 1 of 'USBD_GetString' differ in signedness [-Wpointer-sign]    usbd_desc.c    /xlineusb/Src    line 76    C/C++ Problem

 

It is because the the USBD_getString expects unsigned pointer:

void USBD_GetString         (uint8_t *desc, uint8_t *unicode, uint16_t *len);

 

I would recommend to generate the USB descriptor strings in the following format to prevent these warnings:

/** @defgroup USBD_DESC_Private_Defines
  * @{
  */

#define USBD_VID     1155
#define USBD_LANGID_STRING     1033
#define USBD_MANUFACTURER_STRING     (uint8_t*)("Digitroll Ltd.")
#define USBD_PID_FS     22336
#define USBD_PRODUCT_STRING_FS     (uint8_t*)("XLiNE-USB Converter")
#define USBD_SERIALNUMBER_STRING_FS     (uint8_t*)("00000000001A")
#define USBD_CONFIGURATION_STRING_FS     (uint8_t*)("CDC Config")
#define USBD_INTERFACE_STRING_FS     (uint8_t*)("CDC Interface")

 

Thanks in advance an let me know if you need any further details!

Outcomes