Skip to content

Commit

Permalink
Update sn3d.h
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeshingles committed Oct 26, 2024
1 parent 03ef866 commit 439c9c0
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions sn3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,13 @@ inline void print_line_start() {
}
*/

template <typename... T>
__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<T>(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();
Expand Down

0 comments on commit 439c9c0

Please sign in to comment.