Quantcast

64-bit enum

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

64-bit enum

Brian Cain via cfe-dev
Can we make enums 64 bit at least when compiling for 64 bit platforms? I don't understand why they're limited to (SIGNED) 32 bit, it just doesn't make any sense.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 64-bit enum

Brian Cain via cfe-dev
The C standard says that enum type is 'int':

"The expression that defines the value of an enumeration constant shall be an integer constant expression that has a value representable as an int."

In C++11 you can specify the type.

..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB  Warfvinges väg 34  SE-112 51 Stockholm  Sweden

Mobile:                 +46 (0)709 12 42 62
E-mail:                 [hidden email]

www.evidente.se

________________________________________
From: cfe-dev [[hidden email]] on behalf of Marcus Johnson via cfe-dev [[hidden email]]
Sent: 05 April 2017 05:08
To: [hidden email]
Subject: [cfe-dev] 64-bit enum

Can we make enums 64 bit at least when compiling for 64 bit platforms? I don't understand why they're limited to (SIGNED) 32 bit, it just doesn't make any sense.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

64-bit enum

Brian Cain via cfe-dev
In reply to this post by Brian Cain via cfe-dev
This ends up being a bad idea for a few reasons, and unnecessary for another.  Having different sized enums on different platforms is pretty terrible, and is likely a breaking change.

Additionally, it a waste of memory in the 99% of situations where it is unnecessary.   I personally don't want my 3-4 item enums to inflate the size of my PODs for the 1% case.

That said, it isn't that big of a deal, since you are totally welcome to specify the size of your enum as of C++11.  Simply:

enum Foo : uint64_t {A,B,C};
enum Bar : __int128_t {D,E,F};

------------------------------

Message: 3
Date: Tue, 4 Apr 2017 23:08:08 -0400
From: Marcus Johnson via cfe-dev <[hidden email]>
To: [hidden email]
Subject: [cfe-dev] 64-bit enum
Message-ID: <[hidden email]>
Content-Type: text/plain; charset="utf-8"

Can we make enums 64 bit at least when compiling for 64 bit platforms? I don't understand why they're limited to (SIGNED) 32 bit, it just doesn't make any sense.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170404/1ba5732e/attachment-0001.sig>
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Loading...