??? 12/30/04 18:09 Read: times |
#84134 - Almost but not quite. Responding to: ???'s previous message |
It works okay but is pretty much against the rules of "good coding" that is placing all constants/literals in header files and #including them later.
So, say, the .h file contains: #define TEST {(Byte)0x01,(Byte)0x02,(Byte)0x03} extern Byte test[]; then (any) one .c file contains Byte test[] = TEST; This way whoever is to maintain your program (i.e. you in 2 years when you don't remember a thing from it) and wants to change the values of the array, doesn't have to guess which of many .c files that use the array defines it, just looks in the global "constants" header file where all such constants should be, possibly with rich comments about meaning of each of them. Unless of course you're 100% sure the array will never ever need to be changed. Then it's just a good habit to define constants in headers. (another good habit in C is to name macros with CAPS and variables in lowercase) |
Topic | Author | Date |
How to #define an array | 01/01/70 00:00 | |
not an array | 01/01/70 00:00 | |
if you really mean an array | 01/01/70 00:00 | |
Let me clarify myself a bit | 01/01/70 00:00 | |
extern | 01/01/70 00:00 | |
thanks | 01/01/70 00:00 | |
the space is the place ... | 01/01/70 00:00 | |
Answer is wrong - in part | 01/01/70 00:00 | |
you're correct, of course!![]() | 01/01/70 00:00 | |
memory spaces | 01/01/70 00:00 | |
Almost but not quite. | 01/01/70 00:00 | |
being sure | 01/01/70 00:00 | |
oh.. | 01/01/70 00:00 | |
Back to basics | 01/01/70 00:00 |