PDA

Click to See Complete Forum and Search --> : Enumerations


CornedBee
Oct 24th, 2001, 01:25 PM
Can I change the data type of an enumeration?
I think enums are 32-bit by default, what if I want a 64-bit?

amac
Oct 24th, 2001, 02:01 PM
Maybe they are when using a 64-bit processor...

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

jim mcnamara
Oct 24th, 2001, 02:04 PM
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 ---


main(){
enum modes {
mode1 = 1,
mode2 = 2
}
long i;
i = (long) mode1;
}


Why -- are you getting errors?

amac
Oct 24th, 2001, 02:14 PM
But that is just storing a "32-bit" value into a 64-bit data type.

what about this...



enum CHECKITOUT
{

ITEM1 = 2200000000

}




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

filburt1
Oct 24th, 2001, 02:25 PM
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?

CornedBee
Oct 25th, 2001, 08:45 AM
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?