flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

comile issues flatbuffers/stl_emulation.h:293:58: error: lambda-expression in template-argument typename std::conditional<std::is_convertible<U (*)[], E (*)[]>::value

Open yangqun opened this issue 3 years ago • 2 comments

hello, I downloaded version 2.0.5 on my centos 7.6. and cmake -G “Unix Makefiles”
make make install and I copied an fbs file // Example IDL file for our monster's schema.

namespace MyGame.Sample;

enum Color:byte { Red = 0, Green, Blue = 2 }

union Equipment { Weapon } // Optionally add more tables.

struct Vec3 { x:float; y:float; z:float; }

table Monster { pos:Vec3; mana:short = 150; hp:short = 100; name:string; friendly:bool = false (deprecated); inventory:[ubyte]; color:Color = Blue; weapons:[Weapon]; equipped:Equipment; path:[Vec3]; }

table Weapon { name:string; damage:short; }

root_type Monster; and then : flatc --cpp -o ./ ./monster.fbs and then just included this generated h file in my cmake project. after type make, errors occures: /usr/local/include/flatbuffers/stl_emulation.h:293:58: error: lambda-expression in template-argument typename std::conditional<std::is_convertible<U ()[], E ()[]>::value ^ /usr/local/include/flatbuffers/stl_emulation.h:293:69: error: template argument 1 is invalid typename std::conditional<std::is_convertible<U ()[], E ()[]>::value ^ /usr/local/include/flatbuffers/stl_emulation.h:295:42: error: template argument 1 is invalid int, void>::type;

                             /usr/local/include/flatbuffers/stl_emulation.h:472:35: error: ‘arr’ was not declared in this scope

flatbuffers::span<U, N> make_span(U(&arr)[N]) FLATBUFFERS_NOEXCEPT { ^ In file included from /usr/local/include/flatbuffers/array.h:21, from /usr/local/include/flatbuffers/flatbuffers.h:22, .... /usr/local/include/flatbuffers/stl_emulation.h:472:46: error: expected ‘;’ before ‘noexcept’ flatbuffers::span<U, N> make_span(U(&arr)[N]) FLATBUFFERS_NOEXCEPT { ^ ; /usr/local/include/flatbuffers/stl_emulation.h:478:56: error: declaration of ‘arr’ as array of references flatbuffers::span<const U, N> make_span(const U(&arr)[N]) FLATBUFFERS_NOEXCEPT { ^ In file included from /usr/local/include/flatbuffers/array.h:20, from /usr/local/include/flatbuffers/flatbuffers.h:22, ... /usr/local/include/flatbuffers/stl_emulation.h:478:59: error: ‘template<class U, long unsigned int N> constexpr flatbuffers::span<const U, N> flatbuffers::make_span(...)’ conflicts with a previous declaration flatbuffers::span<const U, N> make_span(const U(&arr)[N]) FLATBUFFERS_NOEXCEPT {

does anybody meet the same issues like me?

yangqun avatar Jan 10 '22 09:01 yangqun

Can you provide your compiler details?

dbaileychess avatar Jan 26 '22 05:01 dbaileychess

@yangqun Are you using cpprestsdk in your project? Then this might be related to the problem I fixed in this PR https://github.com/google/flatbuffers/pull/7424

marcelkrueger avatar Aug 09 '22 17:08 marcelkrueger

I've had a related issue, because stl_emulation.h in linux does not include the definition for __cpp_lib_span under gcc 12.

A fix for me was to define FLATBUFFERS_USE_STD_SPAN manually.

marcogmaia avatar Dec 07 '22 19:12 marcogmaia

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

github-actions[bot] avatar Jun 07 '23 20:06 github-actions[bot]

This issue was automatically closed due to no activity for 6 months plus the 14 day notice period.

github-actions[bot] avatar Jun 22 '23 20:06 github-actions[bot]