typedef enums are now unsigned?!
typedef enums are now unsigned?!
- Subject: typedef enums are now unsigned?!
- From: Nick Zitzmann <email@hidden>
- Date: Fri, 6 Mar 2009 18:53:25 -0700
So I did RTFM, which in this case is "The C Programming
Language" (ANSI edition), and I'm wondering...
While I was working on a project today, I found something strange. We
have an ObjC method in the project that returns a value of typedef
enum when called. TCPL doesn't say anything about typedef enums, but
it does say that enums are always of type int, so I thought this meant
it was OK to return -1 in the method if an error occurs.
Well, on PPC and X86 the method was indeed returning -1 when an error
occurred, but on PPC64 and X86-64, it was instead returning 2^32-1,
which is SOP for a method returning an unsigned int, not an int. This,
of course, threw off various checks for -1, and flew in the face of
what it says in TCPL.
I was able to work around this by changing the results of an error
from -1 to INT_MAX, but this raises several questions: Why did this
change in the 64-bit compilers, where is this change documented, and
how can this behavior be controlled?
Nick Zitzmann
<http://seiryu.home.comcast.net/>
_______________________________________________
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