Skip to content

Commit 908de78

Browse files
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 fbb61ff commit 908de78

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

hardware/arduino/avr/cores/arduino/Print.h

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class Print
7979
size_t println(double, int = 2);
8080
size_t println(const Printable&);
8181
size_t println(void);
82+
83+
virtual void flush() { /* Empty implementation for backward compatibility */ }
8284
};
8385

8486
#endif

hardware/arduino/avr/cores/arduino/Stream.h

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class Stream : public Print
4848
virtual int available() = 0;
4949
virtual int read() = 0;
5050
virtual int peek() = 0;
51-
virtual void flush() = 0;
5251

5352
Stream() {_timeout=1000;}
5453

hardware/arduino/sam/cores/arduino/Print.h

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class Print
7979
size_t println(double, int = 2);
8080
size_t println(const Printable&);
8181
size_t println(void);
82+
83+
virtual void flush() { /* Empty implementation for backward compatibility */ }
8284
};
8385

8486
#endif

hardware/arduino/sam/cores/arduino/Stream.h

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class Stream : public Print
4848
virtual int available() = 0;
4949
virtual int read() = 0;
5050
virtual int peek() = 0;
51-
virtual void flush() = 0;
5251

5352
Stream() {_timeout=1000;}
5453

0 commit comments

Comments
 (0)