Declare snprintf to fix builds on macOS

For some reason on macOS, the functions `snprintf` and `vsnprintf` are
not in the X/Open 5 (ANSI C89) standard but rather in the X/Open
6 (ISO C99). A simplest solution seems to be to declaring the missing
functions before using them, which is what I did here. Another option
is to use the C99 standard with `#define _XOPEN_SOURCE 600`, which
seems to be an overkill for such a niche issue.

Quoting from the STANDARDS section in `man 3 snprintf` on macOS:

> ...the snprintf() and vsnprintf() functions conform to ISO/IEC
> 9899:1999 (“ISO C99”)...
This commit is contained in:
Matus Laslofi 2023-05-01 07:42:45 +02:00 committed by Devine Lu Linvega
parent ce0cc5a352
commit d2e054346f
1 changed files with 4 additions and 0 deletions

View File

@ -26,6 +26,10 @@
#define PATH_MAX 4096 #define PATH_MAX 4096
#endif #endif
#ifdef __APPLE__
int snprintf(char *, unsigned long, const char *, ...);
#endif
#include "../uxn.h" #include "../uxn.h"
#include "file.h" #include "file.h"