Re: enum size in WinCE compiler
- From: "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com>
- Date: Mon, 7 Jan 2008 08:58:03 -0700
As far as I can tell, no, there's no way to change the size of the enum.
Let me ask you this, though: why would you want to do that? Any memory
savings from reducing the size of an enum is going to be swamped by the
slowness of accessing it, at least on any non-x86 processor. If you have a
packed structure that you're sending over the network or something, you're
best-off just declaring the size of the field as an intrinsic type, char,
short, or whatever, and assigning from your enum, as necessary.
-----
typedef enum { packet1 = 1, packet2 = 2, packet3 = 3 } PacketType;
#pragma pack( push, 1 )
typedef struct
{
char packetType;
short packetLength;
unsigned char packetData[1];
} NetStruct;
#pragma pack( pop )
etc.
packet.packetType = (char)packet1;
-----
Paul T.
"Dinesh" <mittals.dinesh@xxxxxxxxx> wrote in message
news:Ot6g%23FGUIHA.5980@xxxxxxxxxxxxxxxxxxxxxxx
Thanks , Could you please give me the MSDN reference to this extension. I
couldn't see it in WinCE documentation and when I tried using this syntax,
I get compilation errors!
cheers
"James Hayhurst" <jameshay@xxxxxxxxxxxxx> wrote in message
news:evZTA%23BUIHA.4360@xxxxxxxxxxxxxxxxxxxxxxx
I believe you can do something like:
enum MyEnum : unsigned char {
// ...
};
I think that this is an MS specific extension though, so it probably
won't be portable.
-James
"Dinesh" <mittals.dinesh@xxxxxxxxx> wrote in message
news:u$D4ro7TIHA.6036@xxxxxxxxxxxxxxxxxxxxxxx
Hi All,
Is there anyway to alter the size of enum data types with WinCE
compiler? I understand in WinCE OS, a enum data types alwayss assumes 4
bytes. Several compilers like GCC, ARM Compilers definitely provide the
option, why not wince?
cheers,
Mithi
.
- Follow-Ups:
- Re: enum size in WinCE compiler
- From: Paul G. Tobey [eMVP]
- Re: enum size in WinCE compiler
- References:
- enum size in WinCE compiler
- From: Dinesh
- Re: enum size in WinCE compiler
- From: James Hayhurst
- Re: enum size in WinCE compiler
- From: Dinesh
- enum size in WinCE compiler
- Prev by Date: Re: compiling romimage ?
- Next by Date: Re: enum size in WinCE compiler
- Previous by thread: Re: enum size in WinCE compiler
- Next by thread: Re: enum size in WinCE compiler
- Index(es):
Relevant Pages
|