Код: Выделить всё
Location for str1: 200026f8
Location for str2: 20002708
Location for Pixel: 200027a0
Код: Выделить всё
Location for str1: 200027a0
Location for str2: 20002708
Location for Pixel: 200027a0
Я не понимаю, почему это происходит. Вот код, чтобы воспроизвести проблему (main.cpp): < /p>
Код: Выделить всё
#include "Arduino.h"
#include
Adafruit_NeoPixel pixel;
String str1("");
String str2("");
void setup() {
// - setup Serial here
Serial.begin(115200); // USB serial
delay(1200); // provide time for serial to connect
pixel = Adafruit_NeoPixel(1, 25, NEO_GRB + NEO_KHZ800);
// print locations
Serial.println("Location for str1: " + String((uint32_t)str1.c_str(), HEX));
Serial.println("Location for str2: " + String((uint32_t)str2.c_str(), HEX));
Serial.println("Location for Pixel: " + String((uint32_t)pixel.pixels, HEX));
// now realloc string memory
str1.reserve(50); // this will overwrite the location of the pixels
Serial.println("Location for str1: " + String((uint32_t)str1.c_str(), HEX));
Serial.println("Location for str2: " + String((uint32_t)str2.c_str(), HEX));
Serial.println("Location for Pixel: " + String((uint32_t)pixel.pixels, HEX));
}
void loop() {
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... the-progra
Мобильная версия