I am trying to use Pstring.h in an Arduino project (my first one). I have been able to fix some other library issues for Arduino 1.0, but I am not sure how to tackle this one. I have added the PString2 library, but even the example project test_pstring fails the verification. I get the following error:
In file included from test_pstring.cpp:1:
C:\arduino-1.0-windows\arduino-1.0\libraries\PString/PString.h:34: error: conflicting return type specified for 'virtual void PString::write(uint8_t)'
C:\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'
Would someone be able to tell me what is going wrong? I haven't been able to find an answer anywhere, and I am sure I am not the first person who is trying to use PString with 1.0 (should I be using something else?).
---ANSWERED BELOW - Post #8---
Sorry cant really help at the moment but i can suggest going to the prev version and using that, v1.0 has changed the default header file from WProgram.h to Arduino.h, maybe that has something to do with it, iv found a few strange thing myself in 1.0 and also dont worry about using R3's in the older versions, as they work fine for me, just make sure you point to the driver folder in 1.0 for windows to install it, then go back to using the previous one.
I had a quick look at it.
The first problem I had was the example needed to be in it's own folder.
The file test_pstring.pde in examples should be in a sub folder called test_pstring
That didn't make it work. I had a read of http://blog.makezine.com/2011/12/01/arduino-1-0-is-out-heres-what-you-need-to-know/ (http://blog.makezine.com/2011/12/01/arduino-1-0-is-out-heres-what-you-need-to-know/)
They say, "New functionality has been added to Streams (the underlying class that anything that uses .print() statements), Ethernet, Wire (I2C), and low level input/output."
So now I get the same error.
Looks like you will have to go back to 0.22 or find another way to do your printing
What functionality is in the old PString class that is not in the new String class?
The article helped somewhat, and ties into the error message, but it is beyond what I currently understand. Essentially, it is stating that VOID statements must be replaced with SIZE_T statements, but being an idiot and just replacing the offending void in line 34 PString with size_t doesn't fix the issue. But, I do get a different error message. I believe the cpp file also needs to be adjusted, but a simple attempt to change the void Pstring::write to size_t (in conjunction with the other change) just brings about different error messages.
Obviously I am just changing things without any clue as to what I am doing. :)
Obviously I am just changing things without any clue as to what I am doing.
So, why are you doing them? Why do you thing you need the PString class? It has been superseded.
Because PString is referenced by a lot of other scripts, two of which I want to use right now. So the choice is to modify every program that includes PSting or try to update PString. Obvioulsy, if it is possible to fix just PString that would help everyone.
Have you asked the author about this?
My thanks to travist from the SparkFun forum for this answer:
Change line 34 of PString.h to:
virtual size_t write(uint8_t);
And line 29 of Pstring.cpp to:
size_t PString::write(uint8_t b)
And not neccessary but I believe its more correct, add these 2 return lines to Pstring.cpp
size_t PString::write(uint8_t b)
if (_cur + 1 < _buf + _size)
*_cur++ = (char)b;
*_cur = '\0';
I lost half of my day trying to find out how to fix this.