Skip to content

Commit 4667777

Browse files
feat: add Print::vprintf function
This does the same as printf, but (like the vprintf libc function) accepts an already processed va_list to allow other vararg functions to forward their argument lists to this function.
1 parent 81181f1 commit 4667777

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Diff for: cores/arduino/Print.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,17 @@ int Print::printf(const __FlashStringHelper *format, ...)
277277
return retval;
278278
}
279279

280+
int Print::vprintf(const char *format, va_list ap)
281+
{
282+
return vdprintf((int)this, format, ap);
283+
}
284+
285+
int Print::vprintf(const __FlashStringHelper *format, va_list ap)
286+
{
287+
return vdprintf((int)this, (const char*)format, ap);
288+
}
289+
290+
280291
// Private Methods /////////////////////////////////////////////////////////////
281292

282293
size_t Print::printNumber(unsigned long n, uint8_t base)

Diff for: cores/arduino/Print.h

+2
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ class Print {
106106

107107
int printf(const char *format, ...);
108108
int printf(const __FlashStringHelper *format, ...);
109+
int vprintf(const __FlashStringHelper *format, va_list ap);
110+
int vprintf(const char *format, va_list ap);
109111

110112
virtual void flush() { /* Empty implementation for backward compatibility */ }
111113
};

0 commit comments

Comments
 (0)