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”)...
---
src/devices/file.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/devices/file.c b/src/devices/file.c
index a208b8f..bc7c4fd 100644
--- a/src/devices/file.c+++ b/src/devices/file.c
@@ -26,6 +26,10 @@
#define PATH_MAX 4096
#endif
+#ifdef __APPLE__+int snprintf(char *, unsigned long, const char *, ...);+#endif+#include "../uxn.h"
#include "file.h"
--
2.39.0
Thanks Matus,
Someone was hitting that same issue just yesterday, hopefully this
will help them with their issue, merged :)
On 4/30/23, Matus Laslofi <matus@laslofi.sk> wrote:
> 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”)...> ---> src/devices/file.c | 4 ++++> 1 file changed, 4 insertions(+)>> diff --git a/src/devices/file.c b/src/devices/file.c> index a208b8f..bc7c4fd 100644> --- a/src/devices/file.c> +++ b/src/devices/file.c> @@ -26,6 +26,10 @@> #define PATH_MAX 4096> #endif>> +#ifdef __APPLE__> +int snprintf(char *, unsigned long, const char *, ...);> +#endif> +> #include "../uxn.h"> #include "file.h">> --> 2.39.0>>
On Mon, 1 May 2023, Hundred Rabbits wrote:
> Thanks Matus,>> Someone was hitting that same issue just yesterday, hopefully this> will help them with their issue, merged :)
Would
#ifndef snprintf
also work?
I don't have an Apple system to test this with, but @tendigits
reported that this fixed the problem for them.
On 5/1/23, Marcin Cieslak <saper@saper.info> wrote:
> On Mon, 1 May 2023, Hundred Rabbits wrote:>>> Thanks Matus,>>>> Someone was hitting that same issue just yesterday, hopefully this>> will help them with their issue, merged :)>> Would>> #ifndef snprintf>> also work?>
On Tue, 2 May 2023, Sigrid Solveig Haflínudóttir wrote:
> It'd also work, but only because snprintf is not a define. Imo, this is just wrong way to fix this.
Sorry, forget my babble. I've played too much with the macros that day. You are of course correct.
I just dislike the code sprinkled with some crazy system-specific #ifdefs