Browse code

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”)...

Matus Laslofi authored on 01/05/2023 05:42:45 • Devine Lu Linvega committed on 01/05/2023 16:27:49
Showing 1 changed files
... ...
@@ -26,6 +26,10 @@
26 26
 #define PATH_MAX 4096
27 27
 #endif
28 28
 
29
+#ifdef __APPLE__
30
+int snprintf(char *, unsigned long, const char *, ...);
31
+#endif
32
+
29 33
 #include "../uxn.h"
30 34
 #include "file.h"
31 35