“String” function

Status
Not open for further replies.

tonton81

Well-known member
the other day i was testing a String function, and without the return “” or return “whatever” in the function, teensy 3.6 i was testing it on froze and required a hard reboot

example:
something like this froze:

String foo() {
}

and this worked as expected

String foo() {
return “”;
}

not sure if its just me or not :p just throwing it out there
 
Indeed, the compiler prints:

Code:
sketch_dec18a: In function 'String foo()':
sketch_dec18a:2: warning: no return statement in function returning non-void 
 }
 ^
 
it was when i started addin it to the library, it did compile and run though at the beginning when i didnt yet put the returns in, its only when i actually ran the function it locked up... but it did compile for me from cpp file, weird

and yeah i usually fix those returns when needed to keep the compiler happy, but was just scripting away testing things :)
 
if your function handles returns, you have to add a return.
you could put at the end of the function this:
Code:
String foo() {
  return String "";
}

you should return all functions that return anyways, even if your not using the return values
 
Hi,

Just in case it's not obvious, you don't need to do anything with the returned value if you don't want to. You can simply ignore it.

best,
Michael
 
Status
Not open for further replies.
Back
Top