- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just come here to see if I'm the only one have this behavior:
using Creator 4.1 update 1, I found that the option in compiler:
"default char unsigned option = False "
will make the default to signed (i.e. no -fsigned-char appended),
and it was confirmed by compiling and run a check on "char a = 127; a += 1;"
to see if "a == 128" or something else.
Anyone could confirm, or I am the only one has this?
Best,
Solved! Go to Solution.
- Labels:
-
PSoC Creator Software
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Workaround for the issue as follows-
1. Add -fsigned-char to the custom command line arguments in the Build Settings.
2. Only use char to store text. For any other purpose, use signed char, unsigned char, int8_t, or uint8_t instead.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if "default char unsigned option = False " then it will make the default to signed (i.e. no -fsigned-char appended).It is expected behavior
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Even it behaves normal to you, I will try to make more tests on other eval boards (the one in op is
CY8CKIT-043, with CY8C4247-L IIRC) in my hand, since no matter it is
"default char unsigned option = False" or "default char unsigned option = True",
(later one will add "-funsigned-char" to compiler parameters)
the "char a;" declaration always makes it an "unsigned char".
Apparently not works as advertised, IMHO in my case?
I was wondering if there's any other causes, like the codes are too irregular or too complex, or any other.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"default char unsigned option = False "
will make the default to signed (i.e. no -fsigned-char appended),
My bad. This description in the very first post should be:
======================================
"default char unsigned option = False "
will make the default to unsigned (i.e. no -fsigned-char appended),
======================================
. And no matter "False" or "True", it always gives unsigned char if
I didn't assign it "signed" or "unsigned". Like what I typed in previous
post.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I reproduced the issue by assigning a char value into a signed long value.
When "unsigned char" type is used, a positive value 0x00000080 is assigned to the long variable b.
When "signed char" type is used, a negative value 0xFFFFFF80 is assigned.
When "char" type is used and the "Default Char Unsigned" is set to False, a positive value 0x00000080 is assigned. So, it was found that the "char" type is handled as "unsigned char" type.
When "char" type is used and the "Default Char Unsigned" is set to True, a positive value 0x00000080 is assigned. So, it was found that the "char" type is handled as "unsigned char" type.
As the conclusion, The "char" type is handled as "unsigned char" type regardless of the setting of "Default Char Unsigned"
Regards,
Noriaki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Workaround for the issue as follows-
1. Add -fsigned-char to the custom command line arguments in the Build Settings.
2. Only use char to store text. For any other purpose, use signed char, unsigned char, int8_t, or uint8_t instead.