Skip to main content
Knowledgebase
Home
Renesas Electronics Europe - Knowledgebase

Does the compiler arrange variables in order of their definition?

Latest Updated:09/04/2015

Question:

Does the compiler arrange variables in order of their definition?

Answer:

Yes it does, except where reference to a name precedes its definition, in which case the location of the reference relative to the definitions takes precedence.

---------------------------------
extern unsigned char a;
extern unsigned char b;
extern unsigned char c;
unsigned char *p = &b;
unsigned char a;
unsigned char b;
unsigned char c;
---------------------------------

In the case mentioned above, reference to b precedes the definitions of a, b, and c. Thus they are arranged in the order b, then a, followed by c. Furthermore, static variables within functions are placed last.

Suitable Products
C Compiler Package for RH850 Family