From 3f63e270445981bd91ed2e237f1281bc7a9a9c41 Mon Sep 17 00:00:00 2001 From: ESL Date: Sun, 28 Jul 2024 10:17:13 -0400 Subject: [PATCH] minor portability fixes --- Makefile | 3 +++ n.c | 8 +++++--- n.h | 4 ++++ pre/n.sf | 8 +++++--- pre/nsf2h.ssc | 4 ++++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 10f1d58..b9eaa6a 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,9 @@ objects = $(sources:%.c=%.o) all: $(exe) clean: + $(RM) $(objects) + +realclean: $(RM) $(objects) $(exe) install: diff --git a/n.c b/n.c index a38f49c..e596780 100644 --- a/n.c +++ b/n.c @@ -964,8 +964,7 @@ static void wrdatum(obj o, wenv_t *e) { wrc('>', e); } else if (isprocedure(o)) { char buf[60]; - if (isobjptr(hblkref(o, 0))) sprintf(buf, "#", objptr_from_obj(o)); - else sprintf(buf, "#", objptr_from_obj(o)); + sprintf(buf, "#", (void*)objptr_from_obj(o)); wrs(buf, e); } else if (isrecord(o)) { int i, n = recordlen(o); @@ -1027,7 +1026,10 @@ extern char *argv_ref(int idx) #if defined(WIN32) #define cxg_envv _environ -#elif defined(__linux) || defined(__APPLE__) +#elif defined(__linux) +#define cxg_envv environ +#elif defined(__APPLE__) +extern char **environ; #define cxg_envv environ #else /* add more systems? */ char **cxg_envv = { NULL }; diff --git a/n.h b/n.h index 78a06d7..bfb4c92 100644 --- a/n.h +++ b/n.h @@ -2,6 +2,10 @@ #if defined(__clang__) #pragma GCC diagnostic ignored "-Wparentheses-equality" +#pragma GCC diagnostic ignored "-Wignored-attributes" +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-value" +#pragma GCC diagnostic ignored "-Woverlength-strings" #endif /* this is for MS headers; shouldn't affect others */ #define _CRT_SECURE_NO_WARNINGS 1 diff --git a/pre/n.sf b/pre/n.sf index c6ef77b..3c60dc2 100644 --- a/pre/n.sf +++ b/pre/n.sf @@ -1479,8 +1479,7 @@ static void wrdatum(obj o, wenv_t *e) { wrc('>', e); } else if (isprocedure(o)) { char buf[60]; - if (isobjptr(hblkref(o, 0))) sprintf(buf, \"#\", objptr_from_obj(o)); - else sprintf(buf, \"#\", objptr_from_obj(o)); + sprintf(buf, \"#\", (void*)objptr_from_obj(o)); wrs(buf, e); } else if (isrecord(o)) { int i, n = recordlen(o); @@ -1555,7 +1554,10 @@ extern char *argv_ref(int idx) #if defined(WIN32) #define cxg_envv _environ -#elif defined(__linux) || defined(__APPLE__) +#elif defined(__linux) +#define cxg_envv environ +#elif defined(__APPLE__) +extern char **environ; #define cxg_envv environ #else /* add more systems? */ char **cxg_envv = { NULL }; diff --git a/pre/nsf2h.ssc b/pre/nsf2h.ssc index 91ad23b..7337462 100644 --- a/pre/nsf2h.ssc +++ b/pre/nsf2h.ssc @@ -23,6 +23,10 @@ (define *prelude* "#if defined(__clang__) #pragma GCC diagnostic ignored \"-Wparentheses-equality\" +#pragma GCC diagnostic ignored \"-Wignored-attributes\" +#pragma GCC diagnostic ignored \"-Wunused-function\" +#pragma GCC diagnostic ignored \"-Wunused-value\" +#pragma GCC diagnostic ignored \"-Woverlength-strings\" #endif /* this is for MS headers; shouldn't affect others */ #define _CRT_SECURE_NO_WARNINGS 1