CRT: add debug printing function

This commit is contained in:
Christian Göttsche
2021-12-08 13:01:40 +01:00
parent 2ae1906479
commit 1da78b5818
2 changed files with 18 additions and 0 deletions

11
CRT.c
View File

@ -13,6 +13,7 @@ in the source distribution for its full text.
#include <fcntl.h>
#include <langinfo.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -844,6 +845,16 @@ static void dumpStderr(void) {
stderrRedirectNewFd = -1;
}
void CRT_debug_impl(const char* file, size_t lineno, const char* func, const char* fmt, ...) {
va_list args;
fprintf(stderr, "[%s:%zu (%s)]: ", file, lineno, func);
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fprintf(stderr, "\n");
}
#else /* !NDEBUG */
static void redirectStderr(void) {