Closed manhnt9 closed 5 years ago
strange, I installed clang 3.9 and get the same errors. My code is just: BETTER_ENUM(Word, int, Hello, World)
Can you show a complete (perhaps minimal) example that causes this?
I tested on a independent source file, there was no error, but I couldn't integrate it to my current project. Do you have any ideas about what may cause the the errors?
Is the enum declared inside class, or is the file that declares it included inside a class (doesn't look so from the error trace, but just in case)?
It's been a while, so I'm not super familiar with GCC error messages anymore, but IIRC this is the main limitation of Better Enums. See https://github.com/aantron/better-enums#limitations.
Closing. Please reopen if this was not solved and you would like to look into it again.
I know 5.4 is not officially supported but I still report for further development. Please support it if possible. Compile errors on Linux 64-bit gcc 5.4.0
enum.h:577:1: error: ‘namespace’ definition is not allowed here namespace better_enums { \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:247:15: error: local class ‘class main()::Word’ shall not have static data member ‘constexpr const size_t main()::Word::_size_constant’ [-fpermissive] 4, 3, 2, 1)) ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:637:9: note: in expansion of macro ‘BETTER_ENUMS_ID’ BETTER_ENUMS_ID(BETTER_ENUMS_PP_COUNT(VA_ARGS)); \ ^ enum.h:243:5: note: in expansion of macro ‘BETTER_ENUMS_ID’ BETTER_ENUMS_ID(BETTER_ENUMS_PP_COUNT_IMPL(VA_ARGS, 64, 63, 62, 61, 60,\ ^ enum.h:243:21: note: in expansion of macro ‘BETTER_ENUMS_PP_COUNT_IMPL’ BETTER_ENUMS_ID(BETTER_ENUMS_PP_COUNT_IMPL(VA_ARGS, 64, 63, 62, 61, 60,\ ^ enum.h:637:25: note: in expansion of macro ‘BETTER_ENUMS_PP_COUNT’ BETTER_ENUMS_ID(BETTER_ENUMS_PP_COUNT(VA_ARGS)); \ ^ enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:665:1: error: ‘namespace’ definition is not allowed here namespace better_enums { \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:683:1: error: a function-definition is not allowed here before ‘{’ token { \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:688:23: error: qualified-id in declaration before ‘(’ token Enum::_from_value_loop(Enum::_integral value, std::size_t index) \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:699:24: error: qualified-id in declaration before ‘(’ token Enum::_from_string_loop(const char *name, std::size_t index) \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:710:31: error: qualified-id in declaration before ‘(’ token Enum::_from_string_nocase_loop(const char *name, std::size_t index) \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:720:66: error: qualified-id in declaration before ‘(’ token BETTER_ENUMSCONSTEXPR inline Enum::_integral Enum::_to_integral() const \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:726:31: error: qualified-id in declaration before ‘(’ token Enum::_from_integral_unchecked(_integral value) \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:732:29: error: qualified-id in declaration before ‘(’ token Enum::_from_integral_nothrow(_integral value) \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:740:57: error: qualified-id in declaration before ‘(’ token BETTER_ENUMSCONSTEXPR inline Enum Enum::_from_integral(_integral value) \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:739:1: note: in expansion of macro ‘BETTER_ENUMS_IF_EXCEPTIONS’ BETTER_ENUMS_IF_EXCEPTIONS( \ ^ enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:748:54: error: qualified-id in declaration before ‘(’ token ToStringConstexpr inline const char* Enum::_to_string() const \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:758:27: error: qualified-id in declaration before ‘(’ token Enum::_from_string_nothrow(const char *name) \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:766:55: error: qualified-id in declaration before ‘(’ token BETTER_ENUMSCONSTEXPR inline Enum Enum::_from_string(const char *name) \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:765:1: note: in expansion of macro ‘BETTER_ENUMS_IF_EXCEPTIONS’ BETTER_ENUMS_IF_EXCEPTIONS( \ ^ enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:775:34: error: qualified-id in declaration before ‘(’ token Enum::_from_string_nocase_nothrow(const char *name) \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:783:62: error: qualified-id in declaration before ‘(’ token BETTER_ENUMSCONSTEXPR inline Enum Enum::_from_string_nocase(const char *name)\ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:782:1: note: in expansion of macro ‘BETTER_ENUMS_IF_EXCEPTIONS’ BETTER_ENUMS_IF_EXCEPTIONS( \ ^ enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:792:52: error: qualified-id in declaration before ‘(’ token BETTER_ENUMSCONSTEXPR inline bool Enum::_is_valid(_integral value) \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:797:52: error: qualified-id in declaration before ‘(’ token BETTER_ENUMSCONSTEXPR inline bool Enum::_is_valid(const char *name) \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:802:59: error: qualified-id in declaration before ‘(’ token BETTER_ENUMSCONSTEXPR inline bool Enum::_is_valid_nocase(const char *name) \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:807:55: error: qualified-id in declaration before ‘(’ token BETTER_ENUMSCONSTEXPR inline const char* Enum::_name() \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:812:67: error: qualified-id in declaration before ‘(’ token BETTER_ENUMSCONSTEXPR inline Enum::_value_iterable Enum::_values() \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:817:59: error: qualified-id in declaration before ‘(’ token ToStringConstexpr inline Enum::_name_iterable Enum::_names() \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:956:32: error: qualified-id in declaration before ‘(’ token inline int Enum::initialize() \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:824:1: note: in expansion of macro ‘BETTER_ENUMS_DO_DEFINE_INITIALIZE’ DefineInitialize(Enum) \ ^ enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ enum.h:1046:9: note: in expansion of macro ‘BETTER_ENUMS_DEFAULT_DEFINE_INITIALIZE’ BETTER_ENUMS_DEFAULT_DEFINE_INITIALIZE, \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:827:5: error: a function-definition is not allowed here before ‘{’ token { return a._to_integral() == b._to_integral(); } \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:829:5: error: a function-definition is not allowed here before ‘{’ token { return a._to_integral() != b._to_integral(); } \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:831:5: error: a function-definition is not allowed here before ‘{’ token { return a._to_integral() < b._to_integral(); } \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:833:5: error: a function-definition is not allowed here before ‘{’ token { return a._to_integral() <= b._to_integral(); } \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:835:5: error: a function-definition is not allowed here before ‘{’ token { return a._to_integral() > b._to_integral(); } \ ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^ enum.h:837:5: error: a function-definition is not allowed here before ‘{’ token { return a._to_integral() >= b._to_integral(); } ^ enum.h:106:28: note: in definition of macro ‘BETTER_ENUMS_ID’
define BETTER_ENUMS_ID(x) x
enum.h:1039:21: note: in expansion of macro ‘BETTER_ENUMS_TYPE’ BETTER_ENUMS_ID(BETTER_ENUMS_TYPE( \ ^ main.cpp:11:3: note: in expansion of macro ‘BETTER_ENUM’ BETTER_ENUM(Word, int, Hello, World) ^