cancel
Showing results for 
Search instead for 
Did you mean: 

Align variables

neil2399
Associate II
Posted on August 02, 2006 at 14:55

Align variables

3 REPLIES 3
neil2399
Associate II
Posted on August 02, 2006 at 11:49

Hi.

I'm using CrossStudio and a STR712F12.

I'm trying to get my variables to align to 16 bit addresses, i.e. align = 2.

I've created a new memory segment in my memory map and created new program sections under that. Each program section is then allocated a specific address and size in on-chip RAM.

All the variables that I want in those memory locations are then defined in a single .h file.

Like so:

#ifdef _PARAMETERS_

#define _SCOPEP_ __attribute__ ((section(''.parameters'')))

#else

#define _SCOPEP_ extern __attribute__ ((section(''.parameters'')))

#endif

_SCOPEP_ int overflow_count;

_SCOPEP_ int processor_idle;

etc.

Now, I also need those variables to align to 16bits.

I've tried changing the ''Alignment'' option for my program sections to ''2'', but it didn't do what I wanted.

Any help would be appreciated.

Thanks

Neil

sjo
Associate II
Posted on August 02, 2006 at 14:25

use the __attribute__ ((aligned (2))) option.

Regards

sjo

neil2399
Associate II
Posted on August 02, 2006 at 14:55

Hi sjo.

I've already tried that, but it doesn't work either.

I get no errors or warnings, but my variables remain aligned to 4.

Neil