Closed jackjansen closed 3 years ago
@jackjansen oh...I forget this problem. uhmmm, okay I will clear this C/C++ STL issue.
@jackjansen cpp predefined macro is ... Arduino IDE : avr-g++ -dM -E -x c++ /dev/null
esp8266 xtensa-lx106-elf-g++ -dM -E -x c++ /dev/null
esp32 xtensa-esp32-elf-gcc -dM -E -x c++ /dev/null
so I think it's better that separate with ESP8266/ESP32 ifdef flags.
Bah. Apparently the xtensa compilers are not 100% c++11 compatible, if I read the standard correctly you can only set cplusplus to whatever you're fully compatible with. `has_include()` may work, but it's a c++17 feature so not sure if it is supported on older platforms...
The fix for #20 was (apparently) to revert the changes for #18.
18 added use of
std::function
for the callback function (as opposed to C-style function pointers). This enabled use of CoAP-simple-library in C++ programs where you have your callback methods inside objects.Apparently this broke for @al3xsh hence the std::function was reverted for #20.
So, now it is broken for my use case again:-)
A solution that works for both use cases may be to use an ifdef around the include/typedef, so that it works both for older compilers (using a function pointer) and newer ones (using a std::function). Maybe something like (untested):