Re: Pointer signedness
Re: Pointer signedness
- Subject: Re: Pointer signedness
- From: Ken Thomases <email@hidden>
- Date: Wed, 22 Jan 2014 10:08:17 -0600
On Jan 22, 2014, at 9:32 AM, Jan E. Schotsman wrote:
> On Jan 22, 2014, at 3:45 PM, Ken Thomases wrote:
>
>>> I am getting an error "pointer targets differ in signedness" in some code. The pointer is a stack array myArray.
>>> If a change the array declaration from SInt8 myArray[64] to char myArray[64] the error goes away.
>>> This must be a bug in Xcode 3.1.3, right?
>>
>> I don't think so. Whether char is signed or unsigned depends on the compiler and its options. Code which makes the (possibly implicit) assumption that it's one or the other is not portable. It can break when compiled differently. Therefore the warning.
>
> Even if I haven't checked "char Type is unsigned" in the Build options?
I believe so. The warning is about potential problems, not necessarily actual problems. (That's how most warnings are, which is why they're warnings and not errors.) It's dangerous to write code that assumes that "char" is the same as "signed char", even if that happens to be true for your current compilation.
> The Target Info assistent says nothing about this.
Don't know what to tell you about that. Check the gcc man page. Look for -funsigned-char. Note where it says:
> The type "char" is always a distinct type from each of "signed char" or "unsigned char", even though its behavior is always just like one of those two.
That is not precisely on point for this warning, but may inform it.
Regards,
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden