Re: Incorrect warning
Re: Incorrect warning
- Subject: Re: Incorrect warning
- From: Chris Espinosa <email@hidden>
- Date: Mon, 15 Nov 2004 10:31:25 -0800
On Nov 15, 2004, at 10:11 AM, Steve Mills wrote:
Why is this a warning?
DescType x;
if(x != enumAddItemName && x != enumAddItemData) <--this line
generates this warning:
warning: comparison is always true due to limited range of data type
And this:
if(GetAEClass() == cUserScrollList || GetAEClass() ==
cUserTextScroller) <--this line
DescType GetAEClass(void) const { return one of many constants;
}
generates this warning:
warning: comparison is always false due to limited range of data type
All constants used in our AppleEvent code are defined in one large
enum, e.g.:
enum {
enumAddItemName = 'ÜDDN',
enumAddItemData = 'ÜDDD',
cUserTextScroller = 'ÜTSc',
cUserScrollList = 'ÜScL',
etc...
};
In those 4, the first byte is umlaut-U, in case it doesn't make it
through mail. Those 2 warnings are obviously wrong, which makes me
wonder if Xcode/gcc will compile them out when optimizations are
turned on.
Because a) DescType is defined as unsigned; b) your enum is implicitly
signed; and c) your enumerators are all negative. They can never be
equal to an unsigned (i.e. always positive) value.
Chris
_______________________________________________
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