Add a perror() function

This commit is contained in:
apio 2022-10-08 12:42:25 +02:00
parent d6f45c284e
commit ee7558a9b7
2 changed files with 7 additions and 0 deletions

View File

@ -35,6 +35,7 @@ extern "C"
int vsprintf(char*, const char*, va_list);
int vsnprintf(char*, size_t, const char*, va_list);
int puts(const char*);
void perror(const char*);
#ifdef __cplusplus
}

View File

@ -1,3 +1,4 @@
#include <errno.h>
#include <luna.h>
#include <stdio.h>
#include <stdlib.h>
@ -78,4 +79,9 @@ extern "C"
va_end(ap);
return written;
}
void perror(const char* s) // FIXME: Print to stderr, whenever we have an stderr.
{
if (s && *s) { printf("%s: ", s); }
printf("%s\n", strerror(errno));
}
}