Results 1 to 6 of 6

Thread: Enumerations

  1. #1

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Enumerations

    Can I change the data type of an enumeration?
    I think enums are 32-bit by default, what if I want a 64-bit?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  2. #2
    amac
    Guest
    Maybe they are when using a 64-bit processor...

    They are 32-bit on this machine... which of course is 32-bit.

  3. #3
    jim mcnamara
    Guest
    This is legal in ansi C: (long on my machine is 64 bits, int is 32)
    You can cast an enum - it's defined as an int datatype.
    I assume you can do this by casting in VC++:

    i = (int64) myenumVar;

    legal ansi C ---

    Code:
    main(){
        enum modes {
    	    mode1 = 1,
    	    mode2 = 2
    	    }
        long i;
        i = (long) mode1;
    }
    Why -- are you getting errors?

  4. #4
    amac
    Guest
    But that is just storing a "32-bit" value into a 64-bit data type.

    what about this...

    Code:
    enum CHECKITOUT
    {
    
        ITEM1 = 2200000000
    
    }

    2200000000 is larger than a 32-bit datatype... So we would end up with some negative number here.

  5. #5
    An enumeration data type provides mnemonic identifiers for a set of integer values. Borland C++ stores enumerators in a single byte if you uncheck Treat Enums As Ints (O|C|Code Generation) or use the -b flag.
    So maybe a compiler option?

  6. #6

    Thread Starter
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    MSDN doesn't say anything about it. What if I want a set of more than 32 flags (each one is 1 bit)? I want them as enum so I can put them into a class (unlike #define). Do I have to split those flags into two enums?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width