Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 16 of 16

Thread: to_string() doesn't work

  1. #1

    to_string() doesn't work

    the std string library function to_string() don't work, "not declared in this scope"
    Click image for larger version. 

Name:	Teensy to_string().jpg 
Views:	20 
Size:	76.3 KB 
ID:	24199

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,697
    String(zahl) ? why are you using strings? use character arrays, uses less resources without the heap destructions

  3. #3
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,280
    Hm, my arduino does not allow to paste a sreenshot :-(

  4. #4
    Senior Member
    Join Date
    Jul 2020
    Posts
    969
    see this thread: https://forum.pjrc.com/threads/46866-string-help

    Also posting an image of your code makes it impossible to copy and paste the code into an IDE window - few are going
    to help you if you force them to type in your code by hand(!)

  5. #5
    Here the code:
    #include <string>
    using namespace std;

    uint8_t zahl = 10;
    string zahlString;

    void setup() {
    zahlString = to_string(zahl);
    }

    void loop() {

    }
    I don't want to discuss the use of String, string or char arrays. It is simple why doesn't it work, it is standard c++11 function

  6. #6
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,445
    AFAIK you need to use at least GCC 6 for this. I just tested your code with gcc-arm-none-eabi-9-2019-q4. And it compiles without issue. There are a few discussions about this issue on Stackoverflow.

  7. #7
    Is there a simple way to change the compiler version? And why does Teensy use an old version? Normally I work on PlatformIO.

  8. #8
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,445
    https://github.com/TeensyUser/doc/wiki/GCC

    Scroll down to "Switching between different toolchains". I'm usually using VisualTeensy where switching is done by simply changing the setting for the GCC folder. If you find out how to do it in PlatformIO it would be great if you could add some info to the WIKI

  9. #9
    Tried with following .ini on platformIO
    Code:
    [env:teensy41]
    platform = teensy
    board = teensy41
    framework = arduino
    platform_packages = toolchain-gccarmnoneeabi@>1.90000.0
    getting following result
    Code:
    Linking .pio/build/teensy41/firmware.elf
    /Users/sstaub/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld: cannot find -larm_cortexM7lfsp_math

  10. #10
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,445
    Yes, the Wiki link shows how to fix this

  11. #11
    I want to try it for Teensyduino app, but the wiki doesn't help me, I'm working on macOS. The path for Arduino/hardware/tools is different to windows.
    On mac there is a user folder Documents/Arduino/hardware which is empty and in Library/Arduino15/packages I can't find the files for Teensy.
    Maybe the Teensyduino IDE have another path on mac then the Arduino IDE.

  12. #12
    Senior Member
    Join Date
    Jul 2020
    Posts
    969
    Stuff's in /Applications/Teensyduino.app/Contents/Java/hardware/teensy/ for me....

  13. #13
    Followed the wiki and changed to gcc-arm-none-eabi-9-2019-q4. No luck, I get always
    Code:
    cannot find -larm_cortexM7lfsp_math

  14. #14
    Senior Member
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    1,445
    Looks like you didn't copy the libraries to the correct path? Unless the GCC folder structure is different for a MAC, they need to go into the MAC equivalent of this WIN10 folder:

    ...\gcc-arm-none-eabi-9_3-2020-q2\arm-none-eabi\lib

    Click image for larger version. 

Name:	Screenshot 2021-03-28 082935.jpg 
Views:	5 
Size:	66.2 KB 
ID:	24211

    Activating verbose output in Arduino and PIO should help finding the correct folders.
    Last edited by luni; 03-28-2021 at 08:09 AM.

  15. #15
    The file libarm_cortexM7lfsp_math.a is missing in gcc versions higher than 1.5 and must manually copied. wtf

  16. #16
    Senior Member
    Join Date
    Jul 2014
    Posts
    3,150
    Quote Originally Posted by sstaub View Post
    The file libarm_cortexM7lfsp_math.a is missing in gcc versions higher than 1.5 and must manually copied. wtf
    IMHO, If it is not there it should not be used!
    the fact that Arduino/Makefiles are not adapting to changing gcc is not the problem of gcc
    maybe there is an equivalent library, or installation of toolchain is not complete.

    BTW, even if you abbreviate to three letters, it is NOT cool to use insults on a technical forum.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •