Skip to content

Commit ba9d416

Browse files
matthijskooijmancmaglie
authored andcommitted
Move the flush method from Stream to Print
This method originally flushed pending input bytes, which makes sense in Stream. At some point it was changed to flush output bytes instead, but it was never moved to Print to reflect this. Since Stream inherits from Print, this should not really affect any users of the Stream or Print classes. However to prevent problems with existing implementations of the Print class that do not provide a flush() implementation, a default implementation is provided. We should probably remove this at some point in the future, though.
1 parent 716fba8 commit ba9d416

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Diff for: cores/arduino/Print.h

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class Print
8787
size_t println(double, int = 2);
8888
size_t println(const Printable&);
8989
size_t println(void);
90+
91+
virtual void flush() { /* Empty implementation for backward compatibility */ }
9092
};
9193

9294
#endif

Diff for: cores/arduino/Stream.h

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class Stream : public Print
5959
virtual int available() = 0;
6060
virtual int read() = 0;
6161
virtual int peek() = 0;
62-
virtual void flush() = 0;
6362

6463
Stream() {_timeout=1000;}
6564

0 commit comments

Comments
 (0)