From 439c9c07d8593ec8b351c41443a517a4aed9fd61 Mon Sep 17 00:00:00 2001 From: Luke Shingles Date: Sat, 26 Oct 2024 06:11:49 +0100 Subject: [PATCH] Update sn3d.h --- sn3d.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/sn3d.h b/sn3d.h index f80a66265..481570e7d 100644 --- a/sn3d.h +++ b/sn3d.h @@ -125,14 +125,13 @@ inline void print_line_start() { } */ -template -__attribute__((__format__(__printf__, 1, 0))) inline auto printout(const char *fmt, T &&...args) -> void { +__attribute__((__format__(__printf__, 1, 2))) inline auto printout(const char *format, ...) -> void { print_line_start(); - if constexpr (sizeof...(args) > 0) { - snprintf(outputlinebuf, sizeof(outputlinebuf), fmt, std::forward(args)...); - } else { - snprintf(outputlinebuf, sizeof(outputlinebuf), "%s", fmt); - } + va_list args{}; + va_start(args, format); + vsnprintf(outputlinebuf, sizeof(outputlinebuf), format, args); + va_end(args); + outputstartofline = (outputlinebuf[strlen(outputlinebuf) - 1] == '\n'); output_file << outputlinebuf; output_file.flush();