Need Help including struct_mapping

Hey there,
i am new to this forum but using teensy just for a while now.

just now i am stuck with including https://github.com/bk192077/struct_mapping into my project.

i know the library does not perfectly fit as it would require
Code:
-std=c++17
build flag which is not supported as far as i read...

basically the compilation fails at
Code:
#include <optional>
which seems to be a c++17 feature.

i found that change the include to
Code:
#include <experimental/optional>
should provide this feature in c++14, but then i get huge error list of failures (below is just a "short" part). I just wonder if somebody does even see any chance to use struct_mapping with teensy4.1

any hint is welcome, thank you in advance

Code:
                    ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In function 'void struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::map_json_to_struct(T&, int&)':
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:128:2: error: 'detail' has not been declared
  detail::Parser parser(
  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:139:2: error: 'parser' was not declared in this scope
  parser.parse(json_data);
  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: At global scope:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:145:25: error: wrong number of template arguments (1, should be 2)
  std::basic_ostream<char>& json_data,
                         ^
In file included from c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\iostream:39:0,
                 from .pio\libdeps\teensy41\struct_mapping\include/struct_mapping/debug.h:5,
                 from .pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:3,
                 from .pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:6,
                 from lib\jsonMapping/structMain.hpp:2,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\ostream:58:11: note: provided for 'template<class _CharT, class _Traits> class struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std::basic_ostream'
     class basic_ostream : virtual public basic_ios<_CharT, _Traits>
           ^
In file included from .pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:6:0,
                 from lib\jsonMapping/structMain.hpp:2,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:146:7: error: 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std::string' has not been declared
  std::string indent = "",
       ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In function 'void struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::map_struct_to_json(T&, int&, int, bool)':
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:152:2: error: 'detail' has not been declared
  detail::IterateOver::set_null = [&] (const std::string& name)
  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:152:50: error: 'string' in namespace 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std' does not name a type
  detail::IterateOver::set_null = [&] (const std::string& name)
                                                  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:197:4: error: expected ')' before ';' token
   };
    ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In lambda function:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:197:4: error: expected '{' before ';' token
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In function 'void struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::map_struct_to_json(T&, int&, int, bool)':
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:199:2: error: 'detail' has not been declared
  detail::IterateOver::set<bool> = [&] (const std::string& name, bool value)
  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:199:27: error: expected primary-expression before 'bool'
  detail::IterateOver::set<bool> = [&] (const std::string& name, bool value)
                           ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:247:2: error: 'detail' has not been declared
  detail::IterateOver::set<long long> = [&] (const std::string& name, long long value)
  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:247:27: error: expected primary-expression before 'long'
  detail::IterateOver::set<long long> = [&] (const std::string& name, long long value)
                           ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:288:2: error: 'detail' has not been declared
  detail::IterateOver::set<double> = [&] (const std::string& name, double value)
  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:288:27: error: expected primary-expression before 'double'
  detail::IterateOver::set<double> = [&] (const std::string& name, double value)
                           ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:329:2: error: 'detail' has not been declared
  detail::IterateOver::set<std::string> = [&] (const std::string& name, std::string value)
  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:329:27: error: 'string' is not a member of 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std'
  detail::IterateOver::set<std::string> = [&] (const std::string& name, std::string value)
                           ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:329:27: note: suggested alternatives:
In file included from c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\string:39:0,
                 from c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\stdexcept:39,
                 from c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\experimental\optional:50,
                 from src\main.hpp:2,
                 from src\main.cpp:2:
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\stringfwd.h:74:33: note:   'std::__cxx11::string'
   typedef basic_string<char>    string;   
                                 ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\stringfwd.h:74:33: note:   'std::__cxx11::string'
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\stringfwd.h:74:33: note:   'std::__cxx11::string'
In file included from .pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:6:0,
                 from lib\jsonMapping/structMain.hpp:2,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:329:40: error: expected primary-expression before '=' token
  detail::IterateOver::set<std::string> = [&] (const std::string& name, std::string value)
                                        ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:329:58: error: 'string' in namespace 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std' does not name a type
  detail::IterateOver::set<std::string> = [&] (const std::string& name, std::string value)
                                                          ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:373:4: error: expected ')' before ';' token
   };
    ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In lambda function:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:373:4: error: expected '{' before ';' token
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In function 'void struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::map_struct_to_json(T&, int&, int, bool)':
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:375:2: error: 'detail' has not been declared
  detail::IterateOver::start_struct = [&] (const std::string& name)
  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:375:54: error: 'string' in namespace 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std' does not name a type
  detail::IterateOver::start_struct = [&] (const std::string& name)
                                                      ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:418:4: error: expected ')' before ';' token
   };
    ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In lambda function:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:418:4: error: expected '{' before ';' token
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In function 'void struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::map_struct_to_json(T&, int&, int, bool)':
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:420:2: error: 'detail' has not been declared
  detail::IterateOver::end_struct = [&] ()
  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In lambda function:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:422:7: error: expected '(' before 'constexpr'
    if constexpr (debug)
       ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:429:16: error: request for member 'empty' in 'indent', which is of non-class type 'int'
    if (!indent.empty())
                ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:431:18: error: invalid operands of types 'int' and 'const char [2]' to binary 'operator<<'
     json_data << "\n";
                  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:439:17: error: invalid operands of types 'int' and 'const char [2]' to binary 'operator<<'
    json_data << "}";
                 ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In function 'void struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::map_struct_to_json(T&, int&, int, bool)':
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:443:2: error: 'detail' has not been declared
  detail::IterateOver::start_array = [&] (const std::string& name)
  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:443:53: error: 'string' in namespace 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std' does not name a type
  detail::IterateOver::start_array = [&] (const std::string& name)
                                                     ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:483:4: error: expected ')' before ';' token
   };
    ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In lambda function:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:483:4: error: expected '{' before ';' token
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In function 'void struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::map_struct_to_json(T&, int&, int, bool)':
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:485:2: error: 'detail' has not been declared
  detail::IterateOver::end_array = [&] ()
  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In lambda function:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:487:7: error: expected '(' before 'constexpr'
    if constexpr (debug)
       ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:494:16: error: request for member 'empty' in 'indent', which is of non-class type 'int'
    if (!indent.empty())
                ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:496:18: error: invalid operands of types 'int' and 'const char [2]' to binary 'operator<<'
     json_data << "\n";
                  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:504:17: error: invalid operands of types 'int' and 'const char [2]' to binary 'operator<<'
    json_data << "]";
                 ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h: In function 'void struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::map_struct_to_json(T&, int&, int, bool)':
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:508:2: error: 'detail' has not been declared
  detail::Object<T>::iterate_over(source_struct, "");
  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:508:18: error: expected primary-expression before '>' token
  detail::Object<T>::iterate_over(source_struct, "");
                  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/mapper.h:508:19: error: '::iterate_over' has not been declared
  detail::Object<T>::iterate_over(source_struct, "");
                   ^
In file included from lib\jsonMapping/structMain.hpp:2:0,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h: At global scope:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:23:40: error: 'string' in namespace 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std' does not name a type
 inline void reg(V T::* ptr, const std::string& name, Options<U>&& ... options)
                                        ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h: In function 'void struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::reg(V T::*, const int&, Options<U>&& ...)':
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:25:2: error: 'detail' has not been declared
  detail::Object<T>::reg(ptr, name, std::forward<Options<U>>(options)...);
  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:25:18: error: expected primary-expression before '>' token
  detail::Object<T>::reg(ptr, name, std::forward<Options<U>>(options)...);
                  ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:25:19: error: '::reg' has not been declared
  detail::Object<T>::reg(ptr, name, std::forward<Options<U>>(options)...);
                   ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:25:19: note: suggested alternative:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:23:13: note:   'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::reg'
 inline void reg(V T::* ptr, const std::string& name, Options<U>&& ... options)
             ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:25:36: error: 'forward' is not a member of 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std'
  detail::Object<T>::reg(ptr, name, std::forward<Options<U>>(options)...);
                                    ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:25:36: note: suggested alternatives:
In file included from c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\stl_pair.h:59:0,
                 from c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\utility:70,
                 from c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\experimental\optional:48,
                 from src\main.hpp:2,
                 from src\main.cpp:2:
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\move.h:87:5: note:   'std::forward'
     forward(typename std::remove_reference<_Tp>::type&& __t) noexcept
     ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\move.h:87:5: note:   'std::forward'
In file included from lib\jsonMapping/structMain.hpp:2:0,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:25:58: error: expected primary-expression before '>' token
  detail::Object<T>::reg(ptr, name, std::forward<Options<U>>(options)...);
                                                          ^
In file included from lib\jsonMapping/structMain.hpp:5:0,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream: At global scope:
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream:65:51: error: expected template-name before '<' token
     class basic_stringbuf : public basic_streambuf<_CharT, _Traits>
                                                   ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream:65:51: error: expected '{' before '<' token
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream:65:51: error: expected unqualified-id before '<' token
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream:367:53: error: expected template-name before '<' token
     class basic_istringstream : public basic_istream<_CharT, _Traits>
                                                     ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream:367:53: error: expected '{' before '<' token
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream:367:53: error: expected unqualified-id before '<' token
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream:511:53: error: expected template-name before '<' token
     class basic_ostringstream : public basic_ostream<_CharT, _Traits>
                                                     ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream:511:53: error: expected '{' before '<' token
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream:511:53: error: expected unqualified-id before '<' token
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream:655:53: error: expected template-name before '<' token
     class basic_stringstream : public basic_iostream<_CharT, _Traits>
                                                     ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream:655:53: error: expected '{' before '<' token
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream:655:53: error: expected unqualified-id before '<' token
In file included from c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\sstream:813:0,
                 from lib\jsonMapping/structMain.hpp:5,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:44:14: error: expected nested-name-specifier before 'basic_stringbuf'
     typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
              ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:44:29: error: expected initializer before '<' token
     typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
                             ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:78:14: error: expected nested-name-specifier before 'basic_stringbuf'
     typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
              ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:78:29: error: expected initializer before '<' token
     typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
                             ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:129:14: error: expected nested-name-specifier before 'basic_stringbuf'
     typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
              ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:129:29: error: expected initializer before '<' token
     typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
                             ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:147:14: error: expected nested-name-specifier before 'basic_stringbuf'
     typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
              ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:147:29: error: expected initializer before '<' token
     typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
                             ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:195:14: error: expected nested-name-specifier before 'basic_stringbuf'
     typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
              ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:195:29: error: expected initializer before '<' token
     typename basic_stringbuf<_CharT, _Traits, _Alloc>::pos_type
                             ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:226:20: error: expected initializer before '<' token
     basic_stringbuf<_CharT, _Traits, _Alloc>::
                    ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:257:20: error: expected initializer before '<' token
     basic_stringbuf<_CharT, _Traits, _Alloc>::
                    ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:272:25: error: 'basic_stringbuf' is not a class template
   extern template class basic_stringbuf<char>;
                         ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:272:25: error: explicit instantiation of non-template type 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std::basic_stringbuf'
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:273:25: error: 'basic_istringstream' is not a class template
   extern template class basic_istringstream<char>;
                         ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:273:25: error: explicit instantiation of non-template type 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std::basic_istringstream'
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:274:25: error: 'basic_ostringstream' is not a class template
   extern template class basic_ostringstream<char>;
                         ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:274:25: error: explicit instantiation of non-template type 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std::basic_ostringstream'
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:275:25: error: 'basic_stringstream' is not a class template
   extern template class basic_stringstream<char>;
                         ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:275:25: error: explicit instantiation of non-template type 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std::basic_stringstream'
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:278:25: error: 'basic_stringbuf' is not a class template
   extern template class basic_stringbuf<wchar_t>;
                         ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:278:25: error: explicit instantiation of non-template type 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std::basic_stringbuf'
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:279:25: error: 'basic_istringstream' is not a class template
   extern template class basic_istringstream<wchar_t>;
                         ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:279:25: error: explicit instantiation of non-template type 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std::basic_istringstream'
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:280:25: error: 'basic_ostringstream' is not a class template
   extern template class basic_ostringstream<wchar_t>;
                         ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:280:25: error: explicit instantiation of non-template type 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std::basic_ostringstream'
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:281:25: error: 'basic_stringstream' is not a class template
   extern template class basic_stringstream<wchar_t>;
                         ^
c:\users\admin\.platformio\packages\toolchain-gccarmnoneeabi@1.50401.190816\arm-none-eabi\include\c++\5.4.1\bits\sstream.tcc:281:25: error: explicit instantiation of non-template type 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std::basic_stringstream'
In file included from lib\jsonMapping/structMain.hpp:9:0,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
lib\jsonMapping/jsonDrv.hpp:12:1: error: 'jsonDrv' does not name a type
 jsonDrv drv01json;
 ^
lib\jsonMapping/jsonDrv.hpp:17:10: error: 'string' in namespace 'struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::std' does not name a type
     std::string name = []
          ^
lib\jsonMapping/jsonDrv.hpp:21:11: error: expected unqualified-id before ')' token
         }();
           ^
lib\jsonMapping/jsonDrv.hpp: In lambda function:
lib\jsonMapping/jsonDrv.hpp:24:48: error: no matching function for call to 'reg(int struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::jsonDrv::*, const char [6])'
    struct_mapping::reg(&jsonDrv::speed, "speed");
                                                ^
In file included from lib\jsonMapping/structMain.hpp:2:0,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:23:13: note: candidate: template<class T, class V, class ... U, template<class> class ... Options> void struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::reg(V T::*, const int&, Options<U>&& ...)
 inline void reg(V T::* ptr, const std::string& name, Options<U>&& ... options)
             ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:23:13: note:   template argument deduction/substitution failed:
In file included from lib\jsonMapping/structMain.hpp:9:0,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
lib\jsonMapping/jsonDrv.hpp:24:48: note:   cannot convert '"speed"' (type 'const char [6]') to type 'const int&'
    struct_mapping::reg(&jsonDrv::speed, "speed");
                                                ^
lib\jsonMapping/jsonDrv.hpp: In lambda function:
lib\jsonMapping/jsonDrv.hpp:29:52: error: no matching function for call to 'reg(float struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::jsonDrv::*, const char [8])'
    struct_mapping::reg(&jsonDrv::current, "current");
                                                    ^
In file included from lib\jsonMapping/structMain.hpp:2:0,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:23:13: note: candidate: template<class T, class V, class ... U, template<class> class ... Options> void struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::reg(V T::*, const int&, Options<U>&& ...)
 inline void reg(V T::* ptr, const std::string& name, Options<U>&& ... options)
             ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:23:13: note:   template argument deduction/substitution failed:
In file included from lib\jsonMapping/structMain.hpp:9:0,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
lib\jsonMapping/jsonDrv.hpp:29:52: note:   cannot convert '"current"' (type 'const char [8]') to type 'const int&'
    struct_mapping::reg(&jsonDrv::current, "current");
                                                    ^
lib\jsonMapping/jsonDrv.hpp: In lambda function:
lib\jsonMapping/jsonDrv.hpp:34:48: error: no matching function for call to 'reg(bool struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::jsonDrv::*, const char [6])'
    struct_mapping::reg(&jsonDrv::fault, "fault");
                                                ^
In file included from lib\jsonMapping/structMain.hpp:2:0,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:23:13: note: candidate: template<class T, class V, class ... U, template<class> class ... Options> void struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::struct_mapping::reg(V T::*, const int&, Options<U>&& ...)
 inline void reg(V T::* ptr, const std::string& name, Options<U>&& ... options)
             ^
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:23:13: note:   template argument deduction/substitution failed:
In file included from lib\jsonMapping/structMain.hpp:9:0,
                 from src\main.hpp:17,
                 from src\main.cpp:2:
lib\jsonMapping/jsonDrv.hpp:34:48: note:   cannot convert '"fault"' (type 'const char [6]') to type 'const int&'
    struct_mapping::reg(&jsonDrv::fault, "fault");
                                                ^
src\main.cpp: At global scope:
src\main.cpp:89:1: error: expected '}' at end of input
 
ok, after some more testing i figured out that the library uses some other c++17 features, so its probably not possible anyway...

if somebody knows a c++14 compatible json from struct please advice.
 
Are you using the latest TeensyDuino 1.58 beta 2? TD 1.58 updates gcc from 5.4.1 to 11.3.1 and should provide support for C++ 17.

Always let us know which model of Teensy, which version of Arduino and TeensyDuino you are using, and what OS (Windows, Linux, Mac, etc.)
 
I don't know anything about using vscode or platformio, so I can't help you there. I have both Arduino 1.8.19 and Arduino 2.0 installed with TeensyDuino 1.58b2. I looked at the github for struct_mapping, and I see this library is not designed for Arduino. There is a CMake process to build a library. You could try asking your question to the author of struct_mapping, and have you looked at ArduinoJson to see if it meets your needs? It may not be as fancy, but it's more likely to work well in a memory-constrained environment.
 
i am actually using ArduinoJson, but as projects growing, i wanted to include all the json part into c++ struct/class because at some point it gets difficult to keep up with doc["item"] = struct.item; especially when i started with nested Object. Also reusability is a big question imho.

the reason why i wanted to go with struct_mapping is because now i have flat structure json for pub/sub via mqtt to node-red. pub_obj_status01...pub_ob_statusnn also sub_obj_command01..sub_obj_commandnn, this is very slow in the meanwhile.

it is much more efficient to send pub_obj{obj_status01{..},obj_statusnn{..}} and sub_obj{obj_cmd01{..},obj_statusnn{..}}

this sketch is still flat, but i hope you can imagine...

even if i hate typless javascript, i like the ease of porting objects between json and js, so maybe i am just a bit spoiled.
acutally i am a plc guy, so my first projects i was communication via modbustcp, but as either mbtcp as also mqtt have to be implemented from the scratch, i decided to send/receive objects instead of buffer makes life easier on nodered side...

especially the combined registration/initialisation example sounded like it would help me in a great way...

finally i will figure out if memory limitation or fancyness will be the winner ;)

long story short, thank you very much for your effort!

comments regarding my requirements are still welcome, maybe i have to change my approach extensively...
 
i found some ways to replace optional, but as said in #2
...after some more testing i figured out that the library uses some other c++17 features...

i belive that just replacing optional might not do the job finally. As long as i am not able to use c++17 with teensy, it wont work probably.

i will give 1.58beta#2 a try with arduinoide and if there is a chance to use it, i will put more effort in updating platformios framework-arduinoteensy also to 1.58beta#2 because i won't move back to arduinoIDE with complete Project.

thank you
 
Some update to this issue...
i managed to run PlatfromIO with GCC++17

Code:
PLATFORM: Teensy (4.17.0) > Teensy 4.1
HARDWARE: IMXRT1062 600MHz, 512KB RAM, 7.75MB Flash
DEBUG: Current (jlink) External (jlink)
PACKAGES:
 - framework-arduinoteensy @ 1.158.0-beta-2 (1.58) 
 - tool-teensy @ 1.158.0-beta-2 (1.58)
 - toolchain-gccarmnoneeabi @ 1.11.3+rel1
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain+, Compatibility ~ strict
Found 116 compatible libraries
Scanning dependencies...

the outcome is this...

Code:
Compiling .pio\build\teensy41\lib7ed\FNET\service\flash\fnet_flash.c.o
In file included from .pio\libdeps\teensy41\struct_mapping\include/struct_mapping/member.h:4,
                 from .pio\libdeps\teensy41\struct_mapping\include/struct_mapping/object.h:5,
                 from .pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:4,
                 from lib\jsonMapping/jsonDrv.hpp:2,
                 from src\main.hpp:16,
                 from src\main.cpp:2:
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/member_string.h: In instantiation of 'static auto& struct_mapping::MemberString<T>::from_string(const string&) [with T = int; std::string = std::__cxx11::basic_string<char>]':
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/member.h:75:64:   required from 'struct_mapping::detail::Member<T, ObjectType>::Member(const string&, struct_mapping::detail::MemberPtr<T, V>, Options<U>&& ...) [with V = int; U = {}; Options = {}; T = jsonDrv; ObjectType = struct_mapping::detail::Object<jsonDrv, false, false>; std::string = std::__cxx11::basic_string<char>; struct_mapping::detail::MemberPtr<T, V> = int jsonDrv::*]'        
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/object.h:45:15:   required from 'static void struct_mapping::detail::Object<T, <anonymous>, <anonymous> >::reg(struct_mapping::detail::MemberPtr<T, V>, const string&, Options<U>&& ...) [with V = int; U = {}; Options = {}; T = jsonDrv; bool <anonymous> = false; bool <anonymous> = false; struct_mapping::detail::MemberPtr<T, V> = int jsonDrv::*; std::string = std::__cxx11::basic_string<char>]'.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/struct_mapping.h:25:24:   required from 'void struct_mapping::reg(V T::*, const string&, Options<U>&& ...) [with T = jsonDrv; V = int; U = {}; Options = {}; std::string = std::__cxx11::basic_string<char>]'
lib\jsonMapping/jsonDrv.hpp:22:23:   required from here
.pio\libdeps\teensy41\struct_mapping\include/struct_mapping/member_string.h:41:25: error: exception handling disabled, use '-fexceptions' to enable    
   41 |                         throw StructMappingException("MemberString not set for member: " + name);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compiling .pio\build\teensy41\lib7ed\FNET\service\fnet_service.c.o
Compiling .pio\build\teensy41\lib7ed\FNET\service\fs\fnet_fs.c.o
Compiling .pio\build\teensy41\lib7ed\FNET\service\fs\fnet_fs_rom.c.o
*** [.pio\build\teensy41\src\main.cpp.o] Error 1
lib\scale\scale.cpp: In function 'void loopScale()':
lib\scale\scale.cpp:86:15: warning: unused variable 'PubStatus' [-Wunused-variable]
   86 |   const char *PubStatus    = "mfteensy/scale/status";
      |               ^~~~~~~~~
lib\scale\scale.cpp:87:15: warning: unused variable 'PubCalibration' [-Wunused-variable]
   87 |   const char *PubCalibration    = "mfteensy/scale/calibrate";
      |               ^~~~~~~~~~~~~~
lib\scale\scale.cpp:88:15: warning: unused variable 'SubCmd' [-Wunused-variable]
   88 |   const char *SubCmd    = "mfteensy/scale/cmd";
      |               ^~~~~~
lib\scale\scale.cpp:89:8: warning: unused variable 'buffer' [-Wunused-variable]
   89 |   char buffer[256];
      |        ^~~~~~
lib\scale\scale.cpp: In function 'void calibScale(STEP_TYPE&)':
lib\scale\scale.cpp:205:11: warning: unused variable 'weightOnScale' [-Wunused-variable]
  205 |     float weightOnScale = Serial.parseFloat();
      |           ^~~~~~~~~~~~~
lib\scale\scale.cpp: In function 'void readSystemSettings()':
lib\scale\scale.cpp:249:25: warning: comparison of integer expressions of different signedness: 'long int' and 'unsigned int' [-Wsign-compare]
  249 |   if (settingZeroOffset == 0xFFFFFFFF)
      |       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
============================================================= [FAILED] Took 49.82 seconds =============================================================
 *  Der Terminalprozess "C:\Users\Admin\.platformio\penv\Scripts\platformio.exe 'run', '--target', 'upload'" wurde mit folgendem Exitcode beendet: 1. 
 *  Das Terminal wird von Aufgaben wiederverwendet, drücken Sie zum Schließen eine beliebige Taste.

setting build-flag '-fexceptions' exits with linker problem

Code:
Linking .pio\build\teensy41\firmware.elf
.pio\build\teensy41\libFrameworkArduino.a(startup.c.o):(.ARM.exidx.startup+0x0): relocation truncated to fit: R_ARM_PREL31 against `.startup'
.pio\build\teensy41\libFrameworkArduino.a(startup.c.o):(.ARM.exidx.startup+0x8): relocation truncated to fit: R_ARM_PREL31 against `.startup'
.pio\build\teensy41\libFrameworkArduino.a(startup.c.o):(.ARM.exidx.startup+0x10): relocation truncated to fit: R_ARM_PREL31 against `.startup'
.pio\build\teensy41\libFrameworkArduino.a(startup.c.o):(.ARM.exidx.flashmem+0x0): relocation truncated to fit: R_ARM_PREL31 against `.flashmem'        
.pio\build\teensy41\libFrameworkArduino.a(startup.c.o):(.ARM.exidx.flashmem+0x8): relocation truncated to fit: R_ARM_PREL31 against `.flashmem'        
.pio\build\teensy41\libFrameworkArduino.a(startup.c.o):(.ARM.exidx.flashmem+0x10): relocation truncated to fit: R_ARM_PREL31 against `.flashmem'       
.pio\build\teensy41\libFrameworkArduino.a(startup.c.o):(.ARM.exidx.flashmem+0x18): relocation truncated to fit: R_ARM_PREL31 against `.flashmem'       
.pio\build\teensy41\libFrameworkArduino.a(startup.c.o):(.ARM.exidx.flashmem+0x20): relocation truncated to fit: R_ARM_PREL31 against `.flashmem'       
.pio\build\teensy41\libFrameworkArduino.a(startup.c.o):(.ARM.exidx.flashmem+0x28): relocation truncated to fit: R_ARM_PREL31 against `.flashmem'       
.pio\build\teensy41\libFrameworkArduino.a(analog.c.o):(.ARM.exidx.flashmem+0x0): relocation truncated to fit: R_ARM_PREL31 against `.flashmem'
.pio\build\teensy41\libFrameworkArduino.a(tempmon.c.o):(.ARM.exidx.flashmem+0x0): additional relocation overflows omitted from the output
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\teensy41\firmware.elf] Error 1
============================================================= [FAILED] Took 54.29 seconds =============================================================
 *  Der Terminalprozess "C:\Users\Admin\.platformio\penv\Scripts\platformio.exe 'run'" wurde mit folgendem Exitcode beendet: 1. 
 *  Das Terminal wird von Aufgaben wiederverwendet, drücken Sie zum Schließen eine beliebige Taste.


compiling the main project (without <struct_mapping>):
#build OK:
from git
framework-arduinoteensy @ 1.157.220801 (1.57)
tool-teensy @ 1.158.0-beta-2 (1.58)
std=gnu++17
toolchain-gccarmnoneeabi @ 1.50401.190816 (5.4.1)

#build fail:
implementated manually by copying the required files from arduino installation after updating teensyduino to 1.58beta2
framework-arduinoteensy @ 1.158.0-beta-2 (1.58)
tool-teensy @ 1.158.0-beta-2 (1.58)
std=gnu++17
toolchain-gccarmnoneeabi @ 1.50401.190816 (5.4.1)

Code:
Linking .pio\build\teensy41\firmware.elf
c:/users/admin/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: .ARM.exidx has both ordered [`.ARM.exidx.text.__aeabi_atexit' in c:/users/admin/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/fpu/fpv5-d16\libstdc++.a(atexit_arm.o)] and unordered [`.ARM.extab.text._ZSt19__throw_logic_errorPKc' in c:/users/admin/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/lib/armv7e-m/fpu/fpv5-d16\libstdc++.a(functexcept.o)] sections
c:/users/admin/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: final link failed: Bad value
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\teensy41\firmware.elf] Error 1
======================================================================================= [FAILED] Took 74.91 seconds =======================================================================================

#build fail2:
i have implementated manually by copying the required files from arduino installation after updating teensyduino to 1.58beta2
framework-arduinoteensy @ 1.158.0-beta-2 (1.58)
tool-teensy @ 1.158.0-beta-2 (1.58)
std=gnu++17
manually implemented from armDevelopers
toolchain-gccarmnoneeabi11.3.rel1

failed with same linker fault as with the test project (so its not about <struct_mapping> library)

my test project consists of jsonDrv.hpp and jsonDrv.Cpp (function start() is called in main loop())

jsonDrv.hpp:
Code:
#include <Arduino.h>
#include <struct_mapping/struct_mapping.h>

#include <iostream>
#include <sstream>
#include <string>
#include <vector>

void start();


struct jsonDrv
{
    /* data 
    std::string name = []
        {
            struct_mapping::reg(&jsonDrv::name, "name");
            return "";
        }();*/
    int speed = []
		{
			struct_mapping::reg(&jsonDrv::speed, "speed");
			return false;
		} ();
	float current = []
		{
			struct_mapping::reg(&jsonDrv::current, "current");
			return 0;
		} ();
	bool fault = []
		{
			struct_mapping::reg(&jsonDrv::fault, "fault");
			return 0;
		} ();
};

jsonDrv.cpp:
Code:
#include "jsonDrv.hpp"

jsonDrv drv01json;
void start(){
    drv01json.fault = true;
    //drv01json.name = "testdrvjson";

    
	std::ostringstream out_json_data;
	struct_mapping::map_struct_to_json(drv01json, out_json_data, "  ");

	std::cout << out_json_data.str() << std::endl;
}

i will also post to platformio because this will most probably fail because of wrong implementation of gcc and toolchain on my part

sorry for getting you bothered with that, still hoping anybody has a glue
 
Last edited:
json is pretty inefficient and not a good choice for MCUs.
Ok, T4 is fast and has a lot of RAM. There is no magic behind json. Pretty easy to write your own code without a need for c++17.

Example: If you want to read a value from a json string, a simple String.indexOf() + read does it in 2 lines of code, without library. And just ignore line breaks.
Have used that to parse a json from open weather map.


As said, best way would be not to use json.. but of course I don't know your project (and you said nothing about it :) )
 
Last edited:
yes, i think you are right, the effort i have spent trying to get c++17 to work would have been enough to implement my needs myself...

for completeness: my project is to rework a "feeding roboter" with quite a number of signals, drives, scales, encoders, safety features ...

as i need to implement recip management, i decided to remove my old plc and combine microcontroller with node-red frontend, grafana etc.

i started to communicate via modbustcp as i am used to, but for the sake of easy readability (and because i needed for other implementations too) i decided to use mqtt for communication (its easy to create js object from json in node-red) so actually i mostly create json struct in microcontroller and have almost final object in node-red

this is working great with arduinojson, but as the project grows its hard to keep up with manually mapping the variables to the struct, so when i found struct_mapping where i can create a c++ struct with json mapping very easy, i ran into current issue.

regarding your post: it is required to do both directions, reading from json as also creating json

i thought of creating a function wich combines strings created by each function to build the final json, but the exceptions would blow my head and it wont be reusable in other projects as my programming skills are not that deep...
 
Back
Top