Online compile error versus local compile succes

Hi everybody!
What’s wrong in the next snipped?

 if (comma != -1) {       
        String val = number.substring(comma + 1);
        value = val.toFloat();
        number =  number.substring(0, comma);   <- online compile gives an error, local not!
    }
This fails too:
String numb;
 if (comma != -1) {       
        String val = number.substring(comma + 1);
        value = val.toFloat();
        numb =  number.substring(0, comma);   <- online compile gives an error, local not!
    }
The error the online compiler generates is: undefined reference to `String::operator=(String&&)
How about that!

This works:
 if (comma != -1) {       
        String val = number.substring(comma + 1);
        value = val.toFloat();
        String numb =  number.substring(0, comma);   <- online compile: succes!
    }

Am I making a mistake or not?

Are you using the lastest hal branch?

There’s a commit to fix the String related issues but not on the current firmware for the build farm.

2 Likes

Is the HAL branch ment for local compiling, than the answer must be no, I use the code I downloaded a couple of months ago.
But to be clear, locally it compiles fine.

Did you use git to download the files? What does git branch say?

What version of GNU tools are you running? i wonder if that could make a difference…

Im running GNU Tools ARM Embedded 4.8 2014q2, but i think q3 is out now…

I don’t think so, I used the download and install locally tutorial a long time a go.
The GIT plugin is installed but grayed out… I never used it to honest.

ok this line of code fails to compile online:
number = number.substring(0, comma);
This is what I use locally:
arm-none-eabi-g++ (GNU Tools for ARM Embeddee) [ARM/embedded-4_8-branch revision 208322]

The method for the assignment statement you are doing, a reference to String is replaced by a reference to another String (substring always returns a new String) is actually ifdef’ed in the source controlled by #ifdef __GXX_EXPERIMENTAL_CXX0X__.

This experimental flag must be turned ON in your local GCC install and it is off in the cloud compile.

1 Like

BKO, Thanks for the info, it’s not a big deal, but this behavior just tickled my curiosity.
tried this:
#define GXX_EXPERIMENTAL_CXX0X
//next line for testing online versus off line compiling
number = number.substring(0, comma);

And the reply of the online compiler is:

hemko-0.5.cpp:193:0: warning: “GXX_EXPERIMENTAL_CXX0X” redefined [enabled by default]
^
:0:0: note: this is the location of the previous definition
hemko-0.5.o: In function button_press(String)': /spark/compile_server/shared/workspace/3_compile-server2/core-firmware/build/hemko-0.5.cpp:195: undefined reference toString::operator=(String&&)'
collect2: error: ld returned 1 exit status
make: *** [c3765d3fc76754eb87eeb544791192d49464e34e96fe9ccf31ab11652db8.elf] Error 1

Again no big deal, I use another string now. And that works off course!

It looks like you are using the button press library and that turned this on.