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

Variables end up on same address

We are using the Keil C-compiler and uVision when compiling a project for the C166-platform. Latley we have been noticing a strange behaviour of our program. A closer look of the result revealed that a number of variables end up being assigned to the same address. Has anyone else experienced the same problem?

I cant explain why the variables do end up at the same address. There is no #pragama-directive used or any such.
The declaration of the variables are as follow:

In the .h-file:

/*## attribute stEventCOMtoPRORxEnd */
extern struct evCOMtoPRORxEnd stEventCOMtoPRORxEnd [MAX_IRQ_EVENTS];
/*## attribute stEventCOMtoPROTxEnd */
extern struct evCOMtoPROTxEnd stEventCOMtoPROTxEnd [MAX_IRQ_EVENTS];

In the .c-file:

/*## attribute stEventCOMtoPRORxEnd */
struct evCOMtoPRORxEnd stEventCOMtoPRORxEnd [MAX_IRQ_EVENTS];

/*## attribute stEventCOMtoPROTxEnd */
struct evCOMtoPROTxEnd stEventCOMtoPROTxEnd [MAX_IRQ_EVENTS];

When looking at the .m66-file after compiling the following can be observed:

1062D2H stEventCOMtoPRORxEnd VAR --- HDATA0 ?HD0?PPROTOCOL 1062D2H stEventCOMtoPROTxEnd VAR --- HDATA0 ?HD0?PPROTOCOL

A third variable (not related) is also assigned to the same address (1062D2)

Parents
  • Actually, all three variables that ended up on the same address acutally had one thing in common.

    All of them are arrays. All of the sizes were defined in a .h-file that was not directly included.

    So, for some reason the compiler igonerd the fact (didnt even give a warning), that the array sizes were unknown. And later optimezed the output and made all pointers refer to the same address.

    Including the correct .h-file resolved the problem.

Reply
  • Actually, all three variables that ended up on the same address acutally had one thing in common.

    All of them are arrays. All of the sizes were defined in a .h-file that was not directly included.

    So, for some reason the compiler igonerd the fact (didnt even give a warning), that the array sizes were unknown. And later optimezed the output and made all pointers refer to the same address.

    Including the correct .h-file resolved the problem.

Children
No data