Hi all, What is the difference between the data types char and short? According to the book, they are both 8 bits and have the exact same range. Thanks, Steve
"Of course, there's lots of variation: uint8, UBYTE / UWORD / ULONG, and so on." Absolutely - after all, they're just names! However, things like "Word", "DWord", "Long", etc have the definite disadvantage that they are ambiguous: they do not explicitly state the size of the object - which is, after all, the whole point of the excercise! Therefore I always use and recommend (as a 'Search' will show!) U8, S16, etc - as they show both size and signed-ness clearly, explicitly, and succinctly. What more could you want?!
Thats kindda what I thought....just symantics, but I just wanted to make sure. Thanks for the help Steve
I also am not fond of the UBYTE / UWORD style. "WORD", in particular, is really problematic. It ought to mean the natural bus width of the machine -- probably the data bus -- but a lot of people use it to mean "16 bits", even on eight- or 32-bit machines. (And then they proceed to use DWORD to mean "32 bits", since it's twice a "WORD".) Then you stack that usage on top of some hardware device that has a different word width, and also keeps using the word "WORD" in their documentation and/or sample code. Just too confusing, especially since the whole point of the series of typedefs is to give you a way to specify a known, exact, width. C99 has standardized a scheme in <inttypes.h> that serves this purpose -- uint8_t, etc. I'm still trying to talk myself into learning to use it; I've gotten too settled in "my" way. Besides, I dislike the "_t" ANSI-ism. (I know it's a type name, okay? That's why it comes in front of the variable name or inside the cast... You don't have to bludgeon me about the head and shoulders with the fact.) As always, it boils down to whatever works for you.