We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
Can anyone tell me how to instruct Keil to compile char's as unsigned char's by default?
I know that there are some help topics on this issue, but they seem to be giving a precompiler directive to tell the compiler to always compile char's as signed char's....
Thanks! Eric
"The C standard states clearly that "signed char" is same as "char"
No, it doesn't, and it never did.
Quoting C99, 6.2.5, paragraph 15 (emphasis mine): ..."
C90 says the same thing, but in many more words. So now quoting C90, 6.1.2.5 "Types", paragraph 2:
"An object declared as type char is large enough to store any member of the basic execution character set. If a member of the required source character set enumerated in 5.2.1 is stored in a char object, its value is guaranteed to be positive. If other quantities are stored in a char object, the behavior is implementation-defined: the values are treated as either signed or nonnegative integers."
char and signed char are only equivalent in that they occupy the same amount of storage. C90 in the same section, paragraph 4:
"An object declared as type signed char occupies the same amount of storage as a 'plain' char object."
Just for the record: all those "many more words" are still present in C99 (section 6.2.5 now), too. And I think C90 had wording equivalent to 6.2.5 paragraph 15. I chose not to quote the former because the latter gets to the point quicker.
"Just for the record: all those "many more words" are still present in C99 (section 6.2.5 now), too."
To be precise, that's paragraph 3 of the C99 section.
"And I think C90 had wording equivalent to 6.2.5 paragraph 15. I chose not to quote the former because the latter gets to the point quicker."
Only for the first sentence. The second sentence was added in C99.
My referencing C90 is so folks don't throw back some argument about Keil's tools not being C99 compliant. For this particular C issue, C99 or C90, nothing has changed.