C code global variables

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

Fair point about the zero-bss optimisation - I didn't realise that happened (was told otherwise by the person that helped me when I had a similar problem). And surely you're not writing an OS in freebasic? By specific I meant "applies to C++, not to C, which is what you appear to be writing in".
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

JamesM wrote:By specific I meant "applies to C++, not to C, which is what you appear to be writing in".
"C++ specific" essentially means "not normally applicable to other languages than C++", which is why added the remark.
JamesM wrote:And surely you're not writing an OS in freebasic?
I like doing things my own crazy way :mrgreen:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
spectrum
Member
Member
Posts: 37
Joined: Wed Jun 13, 2007 7:06 am

Post by spectrum »

yes, my propblem was only solved in apparence, since i have zeroed the vars for test from the main function, rewriting the linker script, they remain zeroed, so rewriting the linker script seems be the solving action, but was not.

Finally i've seen what really happen debbuging the asm code.

As you said, about gcc, even if the variables are initialized to 0, they are read from the end of code, that is uninitialized memory (bss section).

I will memset to 0 the entire area.

Thanks again
Post Reply