Compiler strange behavior with variable that use the "const" modifier.

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Compiler strange behavior with variable that use the "const" modifier.

1,478件の閲覧回数
Claude_Sylvain
Contributor I
Hello,
 
I am using CodeWarrior V6.4 on Windows XP professionnal, on a project that use the MCF52223 MCU, and I have noticed a strange behavior of the compiler.
 
Below the explanation...
 
When defining an array like the following one:
 
/* +++ */
 
const unsigned char my_array[] = {0x01, 0x02, 0x03, 0x04, 0x05};
 
/* +++ */
 
This array is put in the .rodata section, and that's just what anybody expect.
 
But, when defining the save array with all value as 0x00, like the following:
 
/* +++ */
 
const unsigned char my_array[] = {0x00, 0x00, 0x00, 0x00, 0x00};
 
/* +++ */
 
The array is put in the .bss section !?!?
 
Why?
 
Is it a bug, or some strange feature that I do not understand ?
 
Claude.
Electro-Technica inc.
 
 
 
ラベル(1)
タグ(1)
0 件の賞賛
返信
2 返答(返信)

296件の閲覧回数
CrasyCat
Specialist III
Hello
 
THere is already another thread around that topic.
 
You need to use the pragma explicit_zero_data on
 
Please look at following thread for more details:
 
CrasyCat
0 件の賞賛
返信

296件の閲覧回数
Claude_Sylvain
Contributor I
Thank you.
 
Claude
Electro-Technica inc.
 
0 件の賞賛
返信