-std=c++11 compile issue with Teensy3.6

I am trying to compile code using c++11 with the teensy arduino platform/framework. Without the c++11 flag it builds fine. But with it I am getting these errors. I am trying to use some features in c++11. Just curious if anyone has run in to similar issues and knows how to resolve them. Thanks.

Compiling .pioenvs/teensy36/FrameworkArduino/HardwareSerial1.o
In file included from /Users/jli1/.platformio/packages/framework-arduinoteensy/cores/teensy3/WProgram.h:37:0,
from /Users/jli1/.platformio/packages/framework-arduinoteensy/cores/teensy3/arduino.h:1,
from src/main.cpp:12:
/Users/jli1/.platformio/packages/framework-arduinoteensy/cores/teensy3/WCharacter.h: In function 'boolean isAscii(int)':

/Users/jli1/.platformio/packages/framework-arduinoteensy/cores/teensy3/WCharacter.h:64:22: error: 'isascii' was not declared in this scope
return ( isascii (c) == 0 ? false : true);
/Users/jli1/.platformio/packages/framework-arduinoteensy/cores/teensy3/WCharacter.h: In function 'int toAscii(int)':
/Users/jli1/.platformio/packages/framework-arduinoteensy/cores/teensy3/WCharacter.h:146:20: error: 'toascii' was not declared in this scope
return toascii (c);

@valeros could you help here?

Hi @joe31093!
Since functions isascii and toAsciiviolate C++ standard you need to use -std=gnu++11 (C++11 with GNU extensions) to enable them.

Hi valeros,

Thank you for the reply. Here is a simple test that I ran with build_flags = -std=gnu++11. The flag resolved the above non-standard functions. But, if I understand this correctly, to_string is part of the C++11 standard, how do I get access to that method?

#include <string>

int main()
    float pi = 3.14159265359;
    std::string pi_str = std::to_string(pi);
    return 0;

[ Tue Jul 4 21:43:45 2017] Processing teensy36 (platform: teensy; build_flags: -std=gnu++11; board: teensy36; framework: arduino)
Verbose mode can be enabled via -v, --verbose option
Collected 90 compatible libraries
Looking for dependencies…
Project does not have dependencies
Compiling .pioenvs/teensy36/src/main.o

Compiling .pioenvs/teensy36/FrameworkArduino/AudioStream.o
Compiling .pioenvs/teensy36/FrameworkArduino/DMAChannel.o
Compiling .pioenvs/teensy36/FrameworkArduino/HardwareSerial1.o
src/main.cpp: In function 'int main()':
src/main.cpp:14:26: error: 'to_string' is not a member of 'std'
std::string pi_str = std::to_string(pi);
*** [.pioenvs/teensy36/src/main.o] Error 1
========================== [ERROR] Took 1.84 seconds ==========================

Hi everyone,

fyi, i’ve experienced the same problems with teensy 3.1 (isAscii(int) was not declared in this scope).

Switching the build flags from -std=c++11 to -std=gnu++11 solved it but drove me straight to another problem.

.pioenvs/teensy31/libFrameworkArduino.a(main.o): In function main': /Users/tommodeste/.platformio/packages/framework-arduinoteensy/cores/teensy3/main.cpp:21: undefined reference tosetup’
/Users/tommodeste/.platformio/packages/framework-arduinoteensy/cores/teensy3/main.cpp:23: undefined reference to `loop’

I also faced the problem with ‘to_string’ which doesn’t seem to be a member of ‘std’