Seeed wio terminal - atmelsam - std::vector

Hey, I can’t find clear platform limitations when it comes to newer standards and dynamic allocations in c++.

I have Seeed wio terminal and I’ve used unique_ptr here, but trying to use vector ends with a ton of errors. Isn’t this supported here, can I find information about it somewhere?

Maybe someone have a solution? I tried with and without flags.

[env:seeed_wio_terminal]
platform = atmelsam
board = seeed_wio_terminal
framework = arduino
build_flags =
-std=c++17
-std=gnu++17
monitor_speed = 115200
lib_deps =
seeed-studio/Seeed Arduino RTC @ ~2.0.0
seeed-studio/Seeed_Arduino_LCD @ ~1.6.0

And which ones exactly? You haven’t shown any code or error message.

The following project compiles fine.

Ok, then I hope it’s my problem with code :wink: thanks for help. Here’s my messy draft GitHub - InzynierDomu/wio_time_tracker. Here you can see the error add CI · InzynierDomu/wio_time_tracker@8bee389 · GitHub

The long C++ error messages are blinding you. The smoking gun here was

c:\users\max\.platformio\packages\toolchain-gccarmnoneeabi@1.70201.0\arm-none-eabi\include\c++\7.2.1\bits\stl_algobase.h: In static member function 'static bool __lexicographical_compare<true>::__lc(const _Tp*, const _Tp*, 
const _Up*, const _Up*)':
.pio\libdeps\seeed_wio_terminal\Seeed_Arduino_LCD/TFT_eSPI.h:304:19: error: expected unqualified-id before '(' token
 #define min(a, b) (((a) < (b)) ? (a) : (b))
                   ^
In file included from c:\users\max\.platformio\packages\toolchain-gccarmnoneeabi@1.70201.0\arm-none-eabi\include\c++\7.2.1\vector:60:0,
                 from src\main.cpp:8:
c:\users\max\.platformio\packages\toolchain-gccarmnoneeabi@1.70201.0\arm-none-eabi\include\c++\7.2.1\bits\stl_algobase.h: In function 'bool __lexicographical_compare_aux(_II1, _II1, _II2, _II2)':

The TFT_eSPI.h library is injecting the min and max macros into your translation unit, but that majorly screws up the std::min() and std::max() templates, which are needed for the comparison algorithms defined in stl_algobase.h that is pulled in by vector.

So really what you need to do is

#include "DateTime.h"
#include "RTC_SAMD51.h"
#include "TFT_eSPI.h"

#include <Arduino.h>
// don't screw up STL header code by defining min and max as macros
#undef min
#undef max
#include <vector>

See

See also

P.S.: It also has the same effect when you reorder the include files, so that min() as defined by TFT_eSPI.h is not seen by the code included by vector:

#include <Arduino.h>
#include "DateTime.h"
#include "RTC_SAMD51.h"
#include <vector>
#include "TFT_eSPI.h" // must come after vector include

but this is less intuitive and breaks easily if someone reorders the includes.

Thanks a lot, in fact, in such a long output, such a simple mistake got lost, I didn’t suspect such connection :frowning_face: