Hi,
Is there a way to allow memory overlapping in MDK-ARM?
I have tried to use the "__attribute__((at(address)))" but it does not work.
Ex.
unsigned char array1[20] __attribute__((at(0x20002000))); unsigned char array2[10] __attribute__((at(0x2000200A)));
The 'C' programming language does that for you automatically.
Why do you think that you need to manually create overlapping arrays?
Lets say that array2 was declared as a global variable (but it is not visible on my module). I would want to reuse it again (since it is not really used by the other modules).
And what do you think you can do with pointers?
Such as:
typedef struct { .... } my_strange_thing_1; typedef struct { .... } my_strange_thing_2; typedef struct { .... } my_strange_thing_3; uint8_t bulk[BULK_SIZE]; my_strange_thing_1 *strange_ref1; my_strange_thing_2 *strange_ref2; my_strange_thing_3 *strange_ref3; void map_strange1(void) { assert(BULK_SIZE >= sizeof(my_strange_thing_1); strange_ref1 = my_strange_thing_1; strange_ref2 = NULL; strange_ref3 = NULL; } void map_strange2(void) { assert(BULK_SIZE >= sizeof(my_strange_thing_2); strange_ref1 = NULL; strange_ref2 = my_strange_thing_2; strange_ref3 = NULL; } void map_strange3(void) { assert(BULK_SIZE >= sizeof(my_strange_thing_3); strange_ref1 = NULL; strange_ref2 = NULL; strange_ref3 = my_strange_thing_2; }
or
enum Strange { STRANGE_FREE, STRANGE_1, STRANGE_2, STRANGE_3 }; struct { Strange mapped; union { my_strange_thing_1 strange1; my_strange_thing_2 strange2; my_strange_thing_3 strange3; } } strange_overlapping_data;
"array2 was declared as a global variable (but it is not visible on my module"
So why is it not visible "on your module" ?
Why don't you just make it visible?
"it is not really used by the other modules"
So why is it there if it's not used??!
Sounds like you have basic design flaws, and should be addressing them - rather than introducing further kludges!