how to init a pointer in a structure?

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I just got a warning for the way I init a pointer in a structure:

typedef struct
{
	avr32_spi_t *spi;
} abc;

abc i = 
{
.spi = &AVR32_SPI    // <--- warning!
};

Quote:

warning: initialization discards qualifiers from pointer target type

So what's the correct way to init this pointer in structure then?

Cheng

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just a guess, but I think the avr32_spi_t* pointer has to be declared as a pointer to a volatile.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yes, after adding the volatile, the warning disappeared. Thanks.