Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/16/02 19:02
Read: times


 
#34564 - RE: SDDC: Code var must have initialiser
"What is initializing a variable"

this is when you assign an initial value in the variable definition; eg,
unsigned char test = 1; // Variable definition with initialiser
See any 'C' text book for details.

"why do I have to initialise a variable"

In general, you don't have to, but it's good practice to do so.

In this particular case, I guess SDCC must be assuming that, because you've put it into the code space, you must want it to be a constant and, therefore, you should've given it a value as you won't be able to set it to a value later!

However, that SDCC should insist upon an initialiser here seems unreasonable and unnecessarily restrictive!

"what could I ever do with a code variable, wich content is already defined by the content of my eprom"

A very common use for this sort of constant is fixed message text strings; eg,
code char message[] = "Hello, World!n";




List of 7 messages in thread
TopicAuthorDate
SDDC: Code var must have initialiser            01/01/70 00:00      
RE: SDDC: Code var must have initialiser            01/01/70 00:00      
RE: SDDC: Code var must have initialiser            01/01/70 00:00      
RE: SDDC: Code var must have initialiser            01/01/70 00:00      
RE: SDDC: Code var..., Donald            01/01/70 00:00      
RE: SDDC: Code var..., Donald 2            01/01/70 00:00      
RE: SDDC: Code var..., Donald 2            01/01/70 00:00      

Back to Subject List