This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C166 : locate some variables in a specified area memory

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.

Parents
  • 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.

Reply
  • 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.

Children
No data