aantron / better-enums

C++ compile-time enum to string, iteration, in a single header file
http://aantron.github.io/better-enums
BSD 2-Clause "Simplified" License
1.65k stars 172 forks source link

Fix for Visual Studio 2017 #70

Closed D4koon closed 5 years ago

D4koon commented 5 years ago

Fix for #53 (VS 2017 error) expression must have a constant value

aantron commented 5 years ago

Thanks!

For the patch itself, I would expect this to break Better Enums on all compilers, in particular it should make it impossible to declare Better Enums with = foo syntax, like

BETTER_ENUM(Something, int, A, B = 2)

The = 2 should cause a syntax error in the expansion of the macro, if this patch is applied.

See this article for an explanation of what the macro that the patch editing is doing, in section "Values array."

D4koon commented 5 years ago

With the extra cast it seems to also work with vs17

aantron commented 5 years ago

Thanks, it looks good now :)

Consider this PR accepted :) I want to see if I can find time in the next week or two to update the CI to use modern compilers, then merge this, so it's actually being tested on VS 2017. If I don't have time, I'll merge without updating the CI. So please don't mind the delay :)

aantron commented 5 years ago

Thanks!

I added VS2017 to AppVeyor testing, and ran this PR on it (https://github.com/aantron/better-enums/commit/2d2a6a56481ebe7817b8cadce05ea9d28dee7764).