0

I'm using Ubuntu and arm-none-eabi to crosscompile some baremetal programs for the Raspberry Pi, my problem now is, that this:

 char ch[32];
    const char doubleout[] = "double received: ";
    std::string doublestring;
    std::string outstring;
    const char string[] = "character received: ";
    double received = 0.0;
    TIME_LOOP(0,periode){
        int32_t retVal = uart->read(ch,32);
        if (retVal > 0){
            write(string,sizeof(string)-1);
            write(ch,retVal);
            write("\n",1);

            doublestring = std::string(ch);
            received = std::stod(doublestring);
            outstring = std::to_string(received);
            write(doubleout,sizeof(string)-1);
            write(outstring.c_str(), outstring.length()-1);

        }
    }

Doesn't crosscompile with this error:

uart3.cpp: In member function 'virtual void UartTest::run()':
uart3.cpp:48:16: error: 'stod' is not a member of 'std'
 received = std::stod(doublestring);
            ^
uart3.cpp:49:17: error: 'to_string' is not a member of 'std'
 outstring = std::to_string(received);

Compiling for Linux (amd64/x86) instead works fine, it also compiles when using C-methods, like atof(), but not with string or stod().

Is there a solution for this?

1

I solved the problem by using the compiler option "-std=c++0x".

  • Can you maybe give a bit more detail on how you used it? – Kachamenus Oct 15 '15 at 13:11
  • Can you explain what those options do and why they help in this particular case? – Phil B. Oct 15 '15 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.