I have encountered an error trying to compile code including vector on my core. Ive followed instructions for undefining min and max found elsewhere on this forum. I am unsure of the exact cause. Here is my code:
#include "application.h"
#undef min
#undef max
#include <vector>
unsigned long t = 0;
String ats, hts = "";
std::vector<String> games;
std::vector<String> names;
std::vector<int> scores;
void setup() {
Serial.begin(115200);
Spark.subscribe("hook-response/getScores", gotScoreData, MY_DEVICES);
}
void loop() {
if (millis() >= t+30000) {
Serial.println("Getting Scores...");
Spark.publish("getScores");
for (unsigned int x = 0; x < games.size(); x++ ) {
Serial.println(names[x*2]+": "+scores[x*2]+" "+names[(x*2)+1]+": "+scores[(x*2)+1]);
}
t = millis();
}
}
void gotScoreData(const char *name, const char *data) {
String str = String(data);
games.clear();
names.clear();
scores.clear();
bool open = false;
int start, end = 0;
for (unsigned int x = 0; x < str.length(); x++) {
if (str[x] == '{' && !open) {
start = x;
open = true;
}
else if (str[x] == '}' && open) {
end = x;
open = false;
games.push_back(str.substring(start, end));
}
}
for (unsigned int x = 0; x < games.size(); x++ ) {
scores.push_back(tryExtractString(games[x], "\"ats\":", ",\"htc\"").toInt());
scores.push_back(tryExtractString(games[x], "\"hts\":", ",\"atc\"").toInt());
names.push_back(tryExtractString(games[x], "\"ata\":\"", ",\"rl\""));
names.push_back(tryExtractString(games[x], "\"hta\":\"", ",\"ats\""));
}
}
String tryExtractString(String str, const char* start, const char* end) {
if (str == NULL) {
return NULL;
}
int idx = str.indexOf(start);
if (idx < 0) {
return NULL;
}
int endIdx = str.indexOf(end);
if (endIdx < 0) {
return NULL;
}
return str.substring(idx + strlen(start), endIdx);
}
and here is the error:
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from scoreboard.cpp:1:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
scoreboard.o: In function `construct<String, String>':
/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/arm-none-eabi/include/c++/4.8.4/ext/new_allocator.h:120: undefined reference to `String::String(String&&)'
/usr/local/gcc-arm-embedded-gcc-arm-none-eabi-4_8-2014q2-20140609-linux-tar-bz2/arm-none-eabi/include/c++/4.8.4/ext/new_allocator.h:120: undefined reference to `String::String(String&&)'
collect2: error: ld returned 1 exit status
make: *** [75b6353f2ed5d9d654352a53b6e0e4e63c4708485dbf97847e4dcb8cbe77.elf] Error 1
Any help is appreciated
Thanks in advance