compiling error

i get this error and i dont get what i did wrong can anybody explain what happened thanks for your time guys, note  : i attached the code in the end


[Arduino: 1.8.8 (Windows 7), Board: "Arduino/Genuino Uno"

In file included from C:\Users\user\Documents\Arduino\self\self.ino:28:0:

C:\Users\user\Documents\Arduino\libraries\PString/PString.h:34:16: error: conflicting return type specified for 'virtual void PString::write(uint8_t)'

   virtual void write(uint8_t);

                ^

In file included from C:\Users\user\Desktop\arduino\arduino-1.8.8\hardware\arduino\avr\cores\arduino/Stream.h:26:0,

                 from C:\Users\user\Desktop\arduino\arduino-1.8.8\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,

                 from C:\Users\user\Desktop\arduino\arduino-1.8.8\hardware\arduino\avr\cores\arduino/Arduino.h:232,

                 from sketch\self.ino.cpp:1:

C:\Users\user\Desktop\arduino\arduino-1.8.8\hardware\arduino\avr\cores\arduino/Print.h:51:20: error:   overriding 'virtual size_t Print::write(uint8_t)'

     virtual size_t write(uint8_t) = 0;

                    ^

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
]

selfd.txt (23.7 KB)

self.ino (23.7 KB)

You cannot have two functions, with the same name, and same arguments, and different return values.

Regards,
Ray L.

Does it work if you don't use the PString Library? It tries to override the write function of the Print class but has failed to provide the correct signature for Print::write(). Or maybe the Print interface has changed and the PString library was implemented for a different Arduino Version?

You can dig into the library and change the return type to size_t and should be good to go.

LightuC:
Does it work if you don't use the PString Library? It tries to override the write function of the Print class but has failed to provide the correct signature for Print::write(). Or maybe the Print interface has changed and the PString library was implemented for a different Arduino Version?

You can dig into the library and change the return type to size_t and should be good to go.

the return values is already type size_t

Are you completely sure? Because this

C:\Users\user\Documents\Arduino\libraries\PString/PString.h:34:16: error: conflicting return type specified for 'virtual void PString::write(uint8_t)'

   virtual void write(uint8_t);

says something different. Did you, by any chance, looked into the Print library instead of PString?

LightuC:
Are you completely sure? Because this

C:\Users\user\Documents\Arduino\libraries\PString/PString.h:34:16: error: conflicting return type specified for 'virtual void PString::write(uint8_t)'

virtual void write(uint8_t);




says something different. Did you, by any chance, looked into the Print library instead of PString?

LightuC:
Are you completely sure? Because this

C:\Users\user\Documents\Arduino\libraries\PString/PString.h:34:16: error: conflicting return type specified for 'virtual void PString::write(uint8_t)'

virtual void write(uint8_t);




says something different. Did you, by any chance, looked into the Print library instead of PString?

LightuC:
Are you completely sure? Because this

C:\Users\user\Documents\Arduino\libraries\PString/PString.h:34:16: error: conflicting return type specified for 'virtual void PString::write(uint8_t)'

virtual void write(uint8_t);




says something different. Did you, by any chance, looked into the Print library instead of PString?

here is the library

/*
PString.h - Lightweight printable string class
Copyright (c) 2009 Mikal Hart. All right reserved.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/

#ifndef PString_h
#define PString_h

#include “Print.h”
#include <stdarg.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>

class PString : public Print
{
private:
char *_buf, *_cur;
size_t _size;
virtual void write(uint8_t);

public:

// Basic constructor requires a preallocated buffer
PString(char *buf, size_t size) : _buf(buf), _size(size)
{ begin(); }

// templated constructors allow inline renderings of this type: PString(buf, size, myfloat[, modifier]);
template PString(char *buf, size_t size, T arg) : _buf(buf), _size(size)
{ begin(); print(arg); }

template PString(char *buf, size_t size, T arg, int modifier) : _buf(buf), _size(size)
{ begin(); print(arg, modifier); }

// returns the length of the current string, not counting the 0 terminator
inline const size_t length()
{ return _cur - _buf; }

// returns the capacity of the string
inline const size_t capacity()
{ return _size; }

// gives access to the internal string
inline operator const char *()
{ return _buf; }

// compare to another string
bool operator==(const char *str)
{ return _size > 0 && !strcmp(_buf, str); }

// call this to re-use an existing string
void begin();

// This function allows assignment to an arbitrary scalar value like str = myfloat;
template inline PString &operator =(T arg)
{ begin(); print(arg); return *this; }

// Concatenation str += myfloat;
template inline PString &operator +=(T arg)
{ print(arg); return *this; }

// Safe access to sprintf-like formatting, e.g. str.format(“Hi, my name is %s and I’m %d years old”, name, age);
int format(char *str, …);
};

#endif

mjaffarfr:
here is the library

class PString : public Print
{
private:
char *_buf, *_cur;
size_t _size;
virtual void write(uint8_t);

Doesn't look like 'size_t' to me.

gfvalvo:
Doesn't look like 'size_t' to me.

sorry my bad i used to program in java language , c language is new to me sorry i took so much time from you can this data type is new to me can yo please tell me how to change it sorry again thank you for taking the time

In the .h file replace void with size_t for the write function. Do the same in the .cpp file and add a return value to it.