Using "usb_names.h" doesn't work if my project has c++ code.

Status
Not open for further replies.

avgsuperhero

New member
Hi All,

Creating a new file "usb_desc.c":

Code:
#include <usb_names.h>

#define MANUFACTURER_NAME {'A','B','C'}
#define MANUFACTURER_NAME_LEN 3
#define PRODUCT_NAME {'T','E','S','T'}
#define PRODUCT_NAME_LEN 4
#define SERIAL_NUM {'0','0','0','1'}
#define SERIAL_NUM_LEN 4

struct usb_string_descriptor_struct usb_string_manufacturer_name = {
2 + MANUFACTURER_NAME_LEN * 2,
3,
MANUFACTURER_NAME
};

struct usb_string_descriptor_struct usb_string_product_name = {
2 + PRODUCT_NAME_LEN * 2,
3,
PRODUCT_NAME
};

struct usb_string_descriptor_struct usb_string_serial_number = {
2 + SERIAL_NUM_LEN *2,
3,
SERIAL_NUM
};

It works totally fine, but if I add cpp code, it won't compile and gives me the following error:

Code:
too many initializers for 'uint16_t [0] {aka short unsigned int [0]}'

Any thoughts?
 
Last edited:
I figured it out. The problem was that I was putting
Code:
#include "usb_desc.c"
in my .ino file. When I removed the include, everything worked well.
 
Status
Not open for further replies.
Back
Top