[cfe-dev] 64-bit enum

Keane, Erich via cfe-dev cfe-dev at lists.llvm.org
Wed Apr 5 10:18:08 PDT 2017


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 <cfe-dev at lists.llvm.org>
To: cfe-dev at lists.llvm.org
Subject: [cfe-dev] 64-bit enum
Message-ID: <377AD721-70C6-4F60-96D2-D6F54D7F26DF at gmail.com>
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>


More information about the cfe-dev mailing list