arduino-ide

ESP8266 for Arduino IDE (xtensa-lx106-elf-gcc) and std::map linking error

梦想的初衷 提交于 2019-12-01 20:02:16
Is it possible at all to use map with ESP8266 for Arduino package? Here is my code: #include <map> typedef std::map<int, int> Items; void setup() { Items items; items[2]=5; //items.emplace(4,5); } void loop() { } Here is compilation/linking erorrs: Arduino: 1.6.5 (Windows 8.1), Board: "Generic ESP8266 Module, Serial, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS)" sketch_oct31a.cpp.o: In function `loop': C:\Program Files (x86)\Arduino/sketch_oct31a.ino:11: undefined reference to `std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base

Operator new for Arduino

爱⌒轻易说出口 提交于 2019-12-01 07:48:41
问题 I've been told (specifically in an answer to C++ Standard Library on Arduino, and in Stack Overflow question C++ string and Arduino String. How to combine them? )) that the Arduino compiler does not implement the new operator. However, I've written a program for the Arduino (in the Arduino IDE) which uses it, and it works perfectly. void setup() { Serial.begin(9600); } void loop() { char* array; char c; unsigned arraySize; Serial.write("Enter a 1 digit number.\n"); do { c = Serial.read(); }

Arduino: struct pointer as function parameter

点点圈 提交于 2019-11-28 11:24:53
问题 The code below gives the error: sketch_jul05a:2: error: variable or field 'func' declared void So my question is: how can I pass a pointer to a struct as a function parameter? Code: typedef struct { int a,b; } Struc; void func(Struc *p) { } void setup() { Struc s; func(&s); } void loop() { } 回答1: The problem is, that the Arduino-IDE auto-translates this into C like this: #line 1 "sketch_jul05a.ino" #include "Arduino.h" void func(Struc *p); void setup(); void loop(); #line 1 typedef struct {