I'm renaming one of the methods in my library and I want to keep the old name around as a depreciated method. Both take the same parameters so I tried to alias the function like so:
However, when I use the old function name (readWrite) my returnString is always empty. If I change "readWrite" to "writeRead" in my test code everything works just fine. Is there something special I need to do to pass by reference twice?
I've been starring at this for a few hours and can't see anything wrong, but I don't understand some C++ concepts like pass by reference all that well.
Tried deleting the build files from /tmp and I accidentally opened this in Arduino 1.0.1 when restarting the IDE and it worked just fine there. Still not working 1.0.5.
Your biggest mistake is using the String class in the first place. Classes that rely on dynamic memory allocation (such as String) have no place in embedded software for processors with limited RAM, such as the Arduino.
The reason that your simple test case works but your more complicated one doesn't is that you are running out of RAM. The first two parameters of your original and renamed function have type "String". Every time you call one of these methods, the String object will be copied, using additional RAM. When you call readWrite, the first 2 parameters get copied. When readWrite calls writeRead, these parameters get copied again.
You should be able to avoid the double-copy operation by changing that type of the first 2 parameters of readWrite to "const String&". You may also be able to change the parameters of writeRead in the same way (depending on how you use them) to avoid copying the String obejcts at all. But to a large extent, this is merely postponing the inevitable (i.e. running out of RAM because of using String).