gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Why can not use 'static unsigned short' in c function?

#4017 - ZhouChang - Sun Mar 16, 2003 8:17 am

Hello all,
I use devkitadv tool chains to compile my code.When i add a
static unsigned short var in my c function. Then my code will not work.
I have defined __MultiBootInclude and MUTILBOOT in my files.
If i remove these , then it works.
I don't know why? Is it a word aligment problem?
for example:
Code:

// unsigned short color;
static unsigned short color;//the program will not work using static!!
....

#4019 - Daikath - Sun Mar 16, 2003 8:59 am

Have you tried replacing color with another word?
_________________
?There are no stupid questions but there are a LOT of inquisitive idiots.?

#4020 - ZhouChang - Sun Mar 16, 2003 9:12 am

There is no use. If i add any static unsigned short in c function , it will not works

#4021 - Daikath - Sun Mar 16, 2003 9:44 am

What is color defined as?
_________________
?There are no stupid questions but there are a LOT of inquisitive idiots.?

#4022 - ZhouChang - Sun Mar 16, 2003 10:10 am

If i add a unsigned short varible in any c function event i have no use it in program.Then thel gbafile will not run, it just a black scrren in real GBA or in simulator.

#4029 - DekuTree64 - Sun Mar 16, 2003 5:14 pm

I remember trying to use a static variable too, and got the same result. I guess there's just something wrong with the way GCC handles them or something. Ended up just making it global. No real difference other than code organization.