Hi Kristoff, That syntax is called designated initializers, and is only legal in C. It's one of the few things that are legal in C (C99) and not C++.
I would recommend compiling the file as C, and the rest of your application as C++. Though you'd want to make sure that the header has conditional compilation for C++ that adds 'extern "C" {...}' to avoid name mangling. Matthew On 14/02/17 23:19, kristoff wrote: > Hi, > > > I use libopencm3 on STM32F103 maple-mini clones. > > > Some time ago, I tried the usb_cdcacm examples (see link (1) below) for > serial-over-USB on these devices, which compiles and works nicely. > All very fine. > > > > Now, I would like to use this and combine it with an application that > reads and dumps the data on a a mifare rfid-tag using a nfrc522 > rfid-reader. This is a port of the arduino mfrc522 C++ library to > opencm3. (see link 2 below) > The current version of my application uses the serial UART-port on the > STM32F103 which works great, but I like to use the serial-over-USB > interface. > > > > As my mnf522-application is writen in C++, I need to compile the > "serial-over-usb" code in cdcacm.c (see link 3 below) using C++ instead > of gcc. > > But I get this error: > --- cut here --- cut here --- cut here --- cut here --- > USBserial.h:142:2: error: elements of array 'const usb_interface ifaces > []' have incomplete type > }}; > ^ > USBserial.h:142:2: error: storage size of 'ifaces' isn't known > --- cut here --- cut here --- cut here --- cut here --- > > > > > This relates to this piece of code: > > static const struct usb_interface ifaces[] = {{ > .num_altsetting = 1, > .altsetting = comm_iface, > }, { > .num_altsetting = 1, > .altsetting = data_iface, > }}; > > > (see lines 145 of > https://github.com/libopencm3/libopencm3-examples/blob/master/examples/stm32/f1/stm32-h103/usb_cdcacm/cdcacm.c > and above). > > > These structures are defined in "libopencm3/usb/usbstd.h" here: > /* USB Standard Configuration Descriptor - Table 9-10 */ > struct usb_config_descriptor { > uint8_t bLength; > (...) > /* 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; > (...) > > > > Development is done on an ubuntu 16.04 LTS. gcc is arm-none-eabi-gcc / > gcc version 4.9.3 20141119 (release) [ARM/embedded-4_9-branch revision > 218278] (GNU Tools for ARM Embedded Processors) > > The source of this version of gcc is "gcc4mbed" > > So, my impression is that there are some differences in how gcc compiles > this as C then as C++. > > > > > Did anybody have simular issues? > What version of arm-none-eabi-gcc are you all now using (on ubuntu)? > > > > > Cheerio! Kr. Bonne. > > > > > > (1) > https://github.com/libopencm3/libopencm3-examples/tree/master/examples/stm32/f1/stm32-h103/usb_cdcacm > > (2) https://github.com/miguelbalboa/rfid > > (3) > https://github.com/libopencm3/libopencm3-examples/blob/master/examples/stm32/f1/stm32-h103/usb_cdcacm/cdcacm.c > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, SlashDot.org! http://sdm.link/slashdot > _______________________________________________ > libopencm3-devel mailing list > libopencm3-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/libopencm3-devel ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ libopencm3-devel mailing list libopencm3-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libopencm3-devel