Neargye / magic_enum

Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code
MIT License
4.76k stars 422 forks source link

Is magic_enum supported on WindRiver VxWorks 7 SR 0640 LLVM/Clang 9.0.1 #344

Open fnj7 opened 4 months ago

fnj7 commented 4 months ago

I have a multi-platform project that uses magic_enum.

Have successfully compiled and ran in the following configurations:

Attempting to compile example.cpp using WR Workbench 4.0, VxWorks 7 SR 0640, LLVM/Clang 9.0.1 and am experiencing several compilation issues similar to the following (full compile output can be provided if needed):

[ 50%] Building CXX object magicenum-master/example/CMakeFiles/example.dir/C/TEMP/enum_test/EnumTest/magic_enum-master/example/example.o cd /c/TEMP/enum_test/EnumTest/vsb_SIMNTllvm_LP64/build/magic_enum-master/example && /C/Apps/WindRiver/WorkBench4.0/compilers/llvm-9.0.1.1/WIN64/bin/clang -I/C/TEMP/enum_test/EnumTest/magic_enum-master/include/magic_enum -gdwarf-3 --target=x86_64 -m64 -mcmodel=large -fno-omit-frame-pointer -mno-red-zone -ansi -fno-strict-aliasing -fno-builtin -Dvxworks -DVXWORKS -DRTP -DELF__ -nostdlibinc -nostdinc++ -D_USE_INIT_ARRAY -ftls-model=local-exec -std=c++17 -MD -MP -D_VX_CPU=_VX_SIMNT -D_VX_TOOL_FAMILY=llvm -D_VX_TOOL=llvm -D_VSB_CONFIG_FILE=\"C:/TEMP/enum_test/EnumTest/../vxsim/vsb/h/config/vsbConfig.h\" -IC:/TEMP/enum_test/EnumTest/../vxsim/vsb/share/h -isystem C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public -isystem C:/TEMP/enumtest/EnumTest/../vxsim/vsb/usr/h -Wall -Wextra -pedantic-errors -Werror -std=c++17 -o CMakeFiles/example.dir/C/TEMP/enum_test/EnumTest/magic_enum-master/example/example.o -c C:/TEMP/enum_test/EnumTest/magic_enum-master/example/example.cpp In file included from C:/TEMP/enum_test/EnumTest/magic_enum-master/example/example.cpp:23: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\iostream:4: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\istream:4: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\ostream:4: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\ios:4: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\xlocnum:8: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\streambuf:4: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\xiosbase:4: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\xlocale:6: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\stdexcept:5: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\xstring:6: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\xstring_view:4: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\xmemory0:8: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\xutility:6: In file included from C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\utility:7: C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\type_traits:2988:24: error: no matching constructor for initialization of 'std::equal_to' _NOTHROW_TEST(_Ret(_Func(_STD declval<_Func>(),


C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\type_traits:228:37: note: expanded from macro '_NOTHROW_TEST'
  #define _NOTHROW_TEST(x)      noexcept(x)
                                         ^
C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\type_traits:3006:5: note: in instantiation of template class 'std::_Is_nothrow_callable<true, std::equal_to<void> (char, char), void>' requested here
                : _Is_nothrow_callable<is_function<_Func(_Types...)>::value,
                  ^
C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\type_traits:3037:5: note: in instantiation of template class 'std::is_nothrow_callable<std::equal_to<void> (char, char), void>' requested here
                : is_nothrow_callable<_Func(_Types...)>
                  ^
C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\type_traits:3512:3: note: in instantiation of template class 'std::is_nothrow_invocable<std::equal_to<void>, char, char>' requested here
                is_nothrow_invocable<_Func, _Types...>::value;
                ^
C:/TEMP/enum_test/EnumTest/magic_enum-master/include/magic_enum/magic_enum.hpp:339:15: note: in instantiation of variable template specialization 'std::is_nothrow_invocable_r_v<bool, std::equal_to<void>, char, char>' requested here
         std::is_nothrow_invocable_r_v<bool, BinaryPredicate, char_type, char_type>;
              ^
C:/TEMP/enum_test/EnumTest/magic_enum-master/include/magic_enum/magic_enum.hpp:1358:117: note: in instantiation of function template specialization 'magic_enum::detail::is_nothrow_invocable<std::equal_to<void> >' requested here
[[nodiscard]] constexpr auto enum_cast(string_view value, [[maybe_unused]] BinaryPredicate p = {}) noexcept(detail::is_nothrow_invocable<BinaryPredicate>()) -> detail::enable_if_t<E, optional<std::decay_t<E>>, BinaryPredicate> {
                                                                                                                    ^
C:/TEMP/enum_test/EnumTest/magic_enum-master/example/example.cpp:52:13: note: in instantiation of exception specification for 'enum_cast<Color, magic_enum::detail::enum_subtype::common, std::equal_to<void> >' requested here
  auto c2 = magic_enum::enum_cast<Color>("BLUE");
            ^
C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\xstddef:319:9: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
        struct equal_to<void>
               ^
C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\xstddef:319:9: note: candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided
C:/TEMP/enum_test/EnumTest/../vxsim/vsb/usr/h/public\xstddef:319:9: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 2 were provided
fnj7 commented 4 months ago

Is there any information that can be shared to help me move forward.

Am I trying to do something that is not supported?

Has anyone tried Magic Enum on VxWorks 7 SR0640?

Neargye commented 4 months ago

Hi, I can’t understand what the problem is, and unfortunately I’m not familiar with VxWorks. I found only this issues https://github.com/Neargye/magic_enum/issues/46

fnj7 commented 4 months ago

Hi, I can’t understand what the problem is, and unfortunately I’m not familiar with VxWorks. I found only this issues #46

Thank you for taking the time to look. If I ever figure it out, I will let you know.

fnj7 commented 2 months ago

FYI

I moved to VxWorks 7 24.03 and magic-enum compiled with one issue in magic_enum::enum_index()

If you are interested the compilation errors are: C:/TEMP/test/ngj_lb/dep/magic_enum/include/magic_enum.hpp:1241:18: error: constexpr variable 'index' must be initialized by a constant expression 1241 | constexpr auto index = enum_index<std::decay_t<decltype(V)>, S>(V); | ^ ~~~~~~~~~~~ C:/TEMP/test/ngj_lb/projects/ifs/source/Enum.h:359:26: note: in instantiation of function template specialization 'magic_enum::enum_index<EnumTest::TestEnum::NINTH, magic_enum::detail::enum_subtype::common>' requested here 359 | return magic_enum::enum_index(); | ^ C:/TEMP/test/ngj_lb/projects/ifs/test/EnumTest.cpp:134:28: note: in instantiation of function template specialization 'ifs::Enum::index' requested here 134 | EXPECT_EQ(9, ifs::Enum::index()); | ^ C:/TEMP/test/vxworks_bsp/vxsim/vsb/usr/h/public/optional:144:3: note: dynamic memory allocation is not permitted in constant expressions until C++20 144 | ::new ((void *)&this->_Myvalue) _Ty(_STD forward<_U>(_Value)); | ^ C:/TEMP/test/vxworks_bsp/vxsim/vsb/usr/h/public/optional:263:6: note: in call to '_Optional_base(static_cast(v - detail::min_v<D, (magic_enum::detail::enum_subtype)0>))' 263 | : _Mybase(_STD forward<_Uty>(_Right)) | ^ C:/TEMP/test/ngj_lb/dep/magic_enum/include/magic_enum.hpp:1223:14: note: in call to 'optional(static_cast(v - detail::min_v<D, (magic_enum::detail::enum_subtype)0>))' 1223 | return static_cast(v - detail::min_v<D, S>); | ^ C:/TEMP/test/ngj_lb/dep/magic_enum/include/magic_enum.hpp:1241:26: note: in call to 'enum_index(9)' 1241 | constexpr auto index = enum_index<std::decay_t<decltype(V)>, S>(V); | ^ C:/TEMP/test/ngj_lb/dep/magic_enum/include/magic_enum.hpp:1242:17: error: static assertion expression is not an integral constant expression 1242 | static_assert(index, "magic_enum::enum_index enum value does not have a index."); | ^~~~~ C:/TEMP/test/ngj_lb/dep/magic_enum/include/magic_enum.hpp:1242:17: note: initializer of 'index' is not a constant expression C:/TEMP/test/ngj_lb/dep/magic_enum/include/magic_enum.hpp:1241:18: note: declared here 1241 | constexpr auto index = enum_index<std::decay_t<decltype(V)>, S>(V); | ^ 2 errors generated.