adafruit / seesaw

I2C friend to expand capabilities of other chips.
Other
76 stars 34 forks source link

Change initialization to stop warning from occurring #42

Closed Maeur1 closed 3 years ago

Maeur1 commented 3 years ago

When compiling with the latest arm-none-eabi-gcc from here and compiling the soil sensor using make BOARD=soil produces the error:

bsp/bsp_dma.cpp: In function 'void dmac_init()':
bsp/bsp_dma.cpp:30:47: error: 'void* memset(void*, int, size_t)' clearing an object of type 'struct DmacDescriptor' with no trivial copy-assignment; use value-initialization instead [-Werror=class-memaccess]
   30 |     memset(_descriptor, 0, sizeof(_descriptor));
      |                                               ^
In file included from lib/samd10/include/samd10d14am.h:224,
                 from lib/samd10/include/sam.h:42,
                 from bsp/bsp_dma.cpp:8:
lib/samd10/include/component/dmac.h:984:16: note: 'struct DmacDescriptor' declared here
  984 | typedef struct {
      |                ^
bsp/bsp_dma.cpp:31:46: error: 'void* memset(void*, int, size_t)' clearing an object of type 'struct DmacDescriptor' with no trivial copy-assignment; use value-initialization instead [-Werror=class-memaccess]
   31 |     memset(_writeback , 0, sizeof(_writeback));
      |                                              ^
In file included from lib/samd10/include/samd10d14am.h:224,
                 from lib/samd10/include/sam.h:42,
                 from bsp/bsp_dma.cpp:8:
lib/samd10/include/component/dmac.h:984:16: note: 'struct DmacDescriptor' declared here
  984 | typedef struct {
      |                ^
cc1plus: all warnings being treated as errors
make: *** [Makefile:185: build/soil/bsp/bsp_dma.o] Error 1

This fixes this warning by initializing the struct with zeros so there is no need to memset.

ladyada commented 3 years ago

thanks!