• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: typedef enums are now unsigned?!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: typedef enums are now unsigned?!


  • Subject: Re: typedef enums are now unsigned?!
  • From: Jason Stephenson <email@hidden>
  • Date: Sun, 08 Mar 2009 14:08:12 -0400

Ever wish you had an "unsend" button?

using %qi in the printf shows the behavior mentioned by the OP. The question, though is what is the type of TestEnum?

According to a modified version of the program, it is only 4 bytes wide, so printing it as a 64 bit int, will give the behavior seen. I think the question may really be a type mismatch between the enum and the variable to which it is being assigned.

Anyway, I'll butt out now, since I'm just chattering.

Jason

P.S.

#include <stdio.h>

typedef enum {
    Missing = 0,
    Present = 1
} TestEnum;

int main (int argc, char **argv)
{
    TestEnum bob;
    bob = Missing;
    printf("%qi\n", bob);
    bob = -1;
    printf("%qi\n", bob);

    printf("%qi\n", sizeof(TestEnum));
    return 0;
}

_______________________________________________
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


References: 
 >typedef enums are now unsigned?! (From: Nick Zitzmann <email@hidden>)
 >Re: typedef enums are now unsigned?! (From: Clark Cox <email@hidden>)
 >Re: typedef enums are now unsigned?! (From: Darcy Brockbank <email@hidden>)
 >Re: typedef enums are now unsigned?! (From: Jason Stephenson <email@hidden>)
 >Re: typedef enums are now unsigned?! (From: Jason Stephenson <email@hidden>)

  • Prev by Date: Re: typedef enums are now unsigned?!
  • Next by Date: Re: typedef enums are now unsigned?!
  • Previous by thread: Re: typedef enums are now unsigned?!
  • Next by thread: Re: typedef enums are now unsigned?!
  • Index(es):
    • Date
    • Thread