Hello, I use Keil µvision 3.60 I need to store some variables from different files.c in the same memory area in order. I saw there are link directives such ORDER, SECTIONS, GROUPS, but it seems these directives work for all variables or constants from the same file. My problem is my variables are defined in different files and I don't know to specify to store such variable from such file.c in the same defined memory area and the other in the default memory area. I need to specify when I define my variables the allocated memory where are stored. Is possible with Keil Compiler? How can I make this operation? Thanks.
I did not want to use a sturcture because my soft is made by two software teams, and we have to define this structure in a common file and by experience I prefere to share least data (avoid the problem). with my method on another compiler, I had just to copy a memory area, without to know any definition.
Now I have only the choice to use a structure or to define every variable in the same file using the directive ORDER. It is not very good for the architecture of my soft.
It is regrettable that the compiler is limited.
Thank you for your answer.
Complaining that the compiler is limited is most definitely the wrong way to go. It is your imagination that is the limiting factor in this case. It is the poor carpenter who blames his tools...
Anyway. Create one struct in one header file (maintained by one team). Create another struct in another header file for the other team.
Either let the two teams have a pointer each, to a raw block of data, or have a union with the two structs.
If team A only works with code relating to struct A, it doesn't matter to them what happens with struct B. They either uses a_ptr->field or union.a_data.field to access their data.
Of course, mapping two structs above each other can also be done by the linker, but the disadvantage compared to a union is that it isn't visible in the code that you have shared variable space and have to take care when calling functions.
with my method on another compiler, I had just to copy a memory area, without to know any definition.
But the developers still had to know that they had to put the relevant variables into that memory area. That's no better than putting them in a centrally maintained struct datatype.
It's not C166 that is limited here. It's your code's portability that is limited by relying on extensions in some other compiler. Lack of extension is not a limitation.