Hi Everyone,
I am using MicroSoft’s Visual Studio Version 6.0 SP4. Does anyone know
how to default enums as 32-bit integers? It is defaulting to 16-bit (2
bytes). . . .
================
Joe McCloskey
Gamry Instrument
Hi Everyone,
I am using MicroSoft’s Visual Studio Version 6.0 SP4. Does anyone know
how to default enums as 32-bit integers? It is defaulting to 16-bit (2
bytes). . . .
================
Joe McCloskey
Gamry Instrument
wrote in message news:xxxxx@ntdev…
>
> Hi Everyone,
>
> I am using MicroSoft’s Visual Studio Version 6.0 SP4. Does anyone know
> how to default enums as 32-bit integers? It is defaulting to 16-bit (2
> bytes). . . .
Step up to SP5. I ran into that when I was using someone else’s header to
parse a file generated by them. Their compiler used a byte for an enum,
while VS6 SP5 used a DWORD. That one was fun to figure out… I ended up
having to change their header to use a UCHAR in order to make it work, as
#pragma pack(1) didn’t change the allocation for the enum.
Alternatively, assign one explicit value larger than 0xFFFF, and your
compiler should boost your enum size to 32 bits. #pragma pack(4) may
also make it work.
typedef enum _e
{
a = 0,
b,
c,
IWillNeverUseThisValue = 0xFFFFFFFF
} e;
Hope it works for you.
Phil
–
Philip D. Barila
Seagate Technology, LLC
(720) 684-1842
> Alternatively, assign one explicit value larger than 0xFFFF, and your
compiler *should* boost your enum size to 32 bits. #pragma pack(4)
*may*
also make it work.
#pragma pack affects structure member alignment only.
typedef enum _e
{
a = 0,
b,
c,
IWillNeverUseThisValue = 0xFFFFFFFF
} e;
This is a good suggestion, but be aware that using a value >= 0x80000000
will also make the enumerated type unsigned, a potentially undesired
side-effect. If you want to force it to 32 bits but don’t want to
change the signage, use 0x7fffffff.
Chuck
There was a command-line option “treat enums as ints”.
Max
----- Original Message -----
From:
To: “NT Developers Interest List”
Sent: Wednesday, November 27, 2002 8:08 PM
Subject: [ntdev] Treating enums as 32-bit integers.
> Hi Everyone,
>
> I am using MicroSoft’s Visual Studio Version 6.0 SP4. Does anyone
know
> how to default enums as 32-bit integers? It is defaulting to 16-bit
(2
> bytes). . . .
>
> ================
> Joe McCloskey
> Gamry Instrument
>
> —
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to %%email.unsub%%
>