Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
13.1 when initializing with address of volatile variable
#1
13.1 indicates that an initializer list shall not contain persistent side effects, and gives an example of initializing with a volatile variable access. I believe there would be general agreement that
Code:
volatile uint16_t v1;

volatile uint16_t *a[1] = {&v1};
does not count as an "access" and is therefore compliant.

What about address of submembers of a volatile aggregate?
Code:
struct foo
{
    uint16_t bar;
};
volatile struct foo baz;
volatile uint16_t *a[1] = {&baz.bar};

Our cross-compiler defines our microconroller's memory mapped registers by address, like so:
Code:
struct foo
{
    uint16_t bar;
};
#define REG1 (*(volatile uint16_t *)0x100)
#define REG2 (*(volatile struct foo *)0x1000)

volatile uint16_t *a[2] = {&REG1, &REG2.bar};
Are either of the members of this initializer list complaint?
<t></t>


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)