CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

global variables

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hundil
Guest







global variables
PostPosted: Thu Jun 10, 2004 8:29 am     Reply with quote

My Question is very short;

In CCS, Global variables are to be considered as =0 in the beginning,
Or assigned to be any value.
If so, what is the fonction of zero_ram command

thanks for repliers

hundil
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Jun 10, 2004 9:49 am     Reply with quote

I have never assumed ANY variables are zero at start-up unless the chip datasheet says so. Ideally zero_ram would never be needed but with the inevitability of bugs it is possible for the CPU to read a ram location that was never written to, with unpredictable results. Using zero_ram fills all of memory with zero before boot. This can help mitigate "flakey" problems that are hard to eliminate. If your program requires zero_ram to work, it has a problem. Zero_ram doesn't fix problems, it just hides them. But sometime hiding a problem will get you through the day....
_________________
The search for better is endless. Instead simply find very good and get the job done.
Ttelmah
Guest







Re: global variables
PostPosted: Thu Jun 10, 2004 10:12 am     Reply with quote

hundil wrote:
My Question is very short;

In CCS, Global variables are to be considered as =0 in the beginning,
Or assigned to be any value.
If so, what is the fonction of zero_ram command

thanks for repliers

hundil

Zero_ram, ensures that _all_ variables (including non_global ones) will start at zero. Personally, it is quicker, and safer, to code your variale declarations to have the values you want, and only leave 'undeclared' variables that receive values as their first operation. However if you don't want to do this, zero_ram gives you a 'known' starting point, but at the cost of quite a long initialisation sequence. Note that the exact behaviour of variables, has changed slightly with compiler versions, and currently the manual only says that variables declared with the 'static' keyword are initialised to 0 by default. If you want to check how the compiler currently behaves, set up one simple variable of each type, and check what is actually done during initialisation.

best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group