??? 10/31/05 00:25 Read: times |
#103153 - Sloppy terminology Responding to: ???'s previous message |
Oliver Sedlacek said:
The usual way is to have a header file with the variables defined as [b]extern[/b] No - 'extern' is a declaration, not a definition. It is very important to understand the distinction: A definition is what actually causes memory to be allocated. Therefore, if you put definitions in header files, you will get multiple instances of the object - and this will cause Linker errors. Do not do this! A declaration merely provides information (principally type information) to enable the compiler to access an object on the assumption that it is defined somewhere else. Clearly, it is declarations that you want in your header files! Every identifier must be defined exactly once; An identifier may be declared as often as you like. Again, this is basic 'C' textbook stuff - nothing specifically to with SDCC at all! |
Topic | Author | Date |
Using Multiple C files in SDCC | 01/01/70 00:00 | |
Not about the compiler | 01/01/70 00:00 | |
Nothing to do with SDCC | 01/01/70 00:00 | |
The joy of C | 01/01/70 00:00 | |
Sloppy terminology | 01/01/70 00:00 | |
Using Multiple C files in SDCC | 01/01/70 00:00 | |
Laziness | 01/01/70 00:00 | |
example | 01/01/70 00:00 | |
globals are generally bad ... | 01/01/70 00:00 | |
"Generally" being the important word! | 01/01/70 00:00 | |
re Globals![]() | 01/01/70 00:00 | |
static | 01/01/70 00:00 |