Hi everyone,
I’m working in my first project (MIDI related - Control Surface lib) using PlattformIO. I’m trying to build the code available in this example:
Code Example
#include <Arduino.h>
#include <Arduino_Helpers.h> // Include the Arduino Helpers library
#include <AH/Hardware/ExtendedInputOutput/AnalogMultiplex.hpp>
#include <AH/Hardware/FilteredAnalog.hpp>
#include <AH/STL/iterator> // std::back_inserter
#include <AH/STL/vector> // std::vector
// Instantiate a multiplexer
CD74HC4067 mux = {
A0, // analog pin
{3, 4, 5, 6}, // Address pins S0, S1, S2, S3
// 7, // Optionally, specify the enable pin
};
// Convert the list of pins of the multiplexer to an array/vector
// of FilteredAnalog objects.
auto filteredAnalogs = [] {
auto pins = mux.pins();
std::vector<FilteredAnalog<>> v;
v.reserve(pins.length);
std::copy(std::begin(pins), std::end(pins), std::back_inserter(v));
return v;
}(); // This is an immediately invoked lambda expression
void setup() {
Serial.begin(115200);
mux.begin(); // Initialize multiplexer
}
void loop() {
// Loop over all FilteredAnalog objects in the vector
for (auto &analog : filteredAnalogs) {
analog.update(); // actually read the analog value and filter it
Serial.print(analog.getValue());
Serial.print('\t');
}
Serial.println();
}
But I’m getting the error:
Error - Output
PLATFORM: Atmel AVR (2.2.0) > Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)
HARDWARE: ATMEGA2560 16MHz, 8KB RAM, 248KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES:
- framework-arduino-avr 5.0.0
- toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 8 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Control Surface> 1.2.0-4
| |-- <MIDIUSB> 1.0.4
| |-- <SPI> 1.0
| |-- <Encoder> 1.4.1
| |-- <SoftwareSerial> 1.0
|-- <Encoder> 1.4.1
Building in release mode
Compiling .pio/build/megaatmega2560/src/main.cpp.o
In file included from .pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/stl_iterator.h:65:0,
from .pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/iterator:63,
from .pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/iterator:8,
from .pio/libdeps/megaatmega2560/Control Surface/src/AH/Containers/Array.hpp:10,
from .pio/libdeps/megaatmega2560/Control Surface/src/AH/Hardware/Hardware-Types.hpp:8,
from .pio/libdeps/megaatmega2560/Control Surface/src/AH/Hardware/ExtendedInputOutput/ExtendedInputOutput.hpp:14,
from .pio/libdeps/megaatmega2560/Control Surface/src/AH/Hardware/ExtendedInputOutput/AnalogMultiplex.hpp:8,
from src/main.cpp:5:
.pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/../bits/move.h: In instantiation of 'constexpr _Tp* std::__addressof(_Tp&) [with _Tp = std::vector<AH::FilteredAnalog<> >]':
.pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/stl_iterator.h:468:35: required from 'std::back_insert_iterator<_Container>::back_insert_iterator(_Container&) [with _Container = std::vector<AH::FilteredAnalog<> >]'
.pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/stl_iterator.h:534:50: required from 'std::back_insert_iterator<_Container> std::back_inserter(_Container&) [with _Container = std::vector<AH::FilteredAnalog<> >]'
src/main.cpp:30:67: required from here
.pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/../bits/move.h:48:33: error: '__builtin_addressof' was not declared in this scope
{ return __builtin_addressof(__r); }
^
.pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/../bits/move.h:48:40: error: body of constexpr function 'constexpr _Tp* std::__addressof(_Tp&) [with _Tp = std::vector<AH::FilteredAnalog<> >]' not a return-statement
{ return __builtin_addressof(__r); }
^
.pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/../bits/move.h: In instantiation of 'constexpr _Tp* std::__addressof(_Tp&) [with _Tp = AH::FilteredAnalog<>]':
.pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/stl_uninitialized.h:83:35: required from 'static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = std::move_iterator<AH::FilteredAnalog<>*>; _ForwardIterator = AH::FilteredAnalog<>*; bool _TrivialValueTypes = false]'
.pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/stl_uninitialized.h:134:15: required from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = std::move_iterator<AH::FilteredAnalog<>*>; _ForwardIterator = AH::FilteredAnalog<>*]'
.pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/stl_uninitialized.h:289:37: required from '_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = std::move_iterator<AH::FilteredAnalog<>*>; _ForwardIterator = AH::FilteredAnalog<>*; _Tp = AH::FilteredAnalog<>]'
.pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/stl_vector.h:1269:35: required from 'std::vector<_Tp, _Alloc>::pointer std::vector<_Tp, _Alloc>::_M_allocate_and_copy(std::vector<_Tp, _Alloc>::size_type, _ForwardIterator, _ForwardIterator) [with _ForwardIterator = std::move_iterator<AH::FilteredAnalog<>*>; _Tp = AH::FilteredAnalog<>; _Alloc = std::allocator<AH::FilteredAnalog<> >; std::vector<_Tp, _Alloc>::pointer = AH::FilteredAnalog<>*; std::vector<_Tp, _Alloc>::size_type = unsigned int]'
.pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/vector.tcc:73:40: required from 'void std::vector<_Tp, _Alloc>::reserve(std::vector<_Tp, _Alloc>::size_type) [with _Tp = AH::FilteredAnalog<>; _Alloc = std::allocator<AH::FilteredAnalog<> >; std::vector<_Tp, _Alloc>::size_type = unsigned int]'
src/main.cpp:29:24: required from here
.pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/../bits/move.h:48:33: error: '__builtin_addressof' was not declared in this scope
{ return __builtin_addressof(__r); }
^
.pio/libdeps/megaatmega2560/Control Surface/src/AH/STL/Fallback/bits/../bits/move.h:48:40: error: body of constexpr function 'constexpr _Tp* std::__addressof(_Tp&) [with _Tp = AH::FilteredAnalog<>]' not a return-statement
{ return __builtin_addressof(__r); }
^
*** [.pio/build/megaatmega2560/src/main.cpp.o] Error 1
============================================================================= [FAILED] Took 2.33 seconds =============================================================================
According to the library maintainer, it’s probably related to an old compiler I’m currectly using. I should upgrade the Arduino AVR Core to at least version 1.8.1.
He also don’t support PlatformIO users and I don’t exactly how to proceed. I’m not sure exactly what’s the compiler version I’m using neither if it’s possible to update it (I have new installation in my environment).
Does anyone could help me on that?
Thank you in advance!