Domanda

I am clearly missing something obvious, but I am stumped:

I have one source file where I declare all of my global variables, and a header file that matches and makes them all extern. However, when I try to use a pragma provided by my IDE (IAR) to data align a variable there, it does not work. It is placing the variable at an address like 0x20027424. If I move the variable to local, it works fine; the address ends in 0.

What am I missing?

From Vars.c:

#pragma data_alignment=4
u16  g_uCompChk;

From Vars.h:

#pragma data_alignment=4
extern u16  g_uCompChk;
È stato utile?

Soluzione

data_alignment = expression

should give an alignment in bytes, not in multiples of the object size. So an alignment on 4 bytes boundary is to be expected. It seems everything is ok according to the example addresse you provided

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top