Sooora
Sooora

Reputation: 191

How can use __attribute__ (section) for each element of an array?

I have a multidimensional array and I want to define each element of this array in a different section. Something like:

int array [2][200];

array[0] __attribute__((section (".section1")));
array[1] __attribute__((section (".section2")));

I know this piece of code is not correct because __atribute__ ((section "section name")) should be used in the array definition. Do you have any suggestions on how I can do it?

Thanks in advance

Upvotes: 1

Views: 252

Answers (1)

0___________
0___________

Reputation: 67721

No. The array is a contigous chunk of memory and elements cannot be in different sections.

C standard (6.2.5.20):

An array type describes a contiguously allocated nonempty set of objects with a particular member object type, called the element type.

Do you have any suggestions on how I can do it?

You need to have two separate arrays in different sections and array of two pointers referencing those arrays.

Upvotes: 2

Related Questions