summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--args.h8
-rw-r--r--ffi.c6
-rw-r--r--lib.h6
-rw-r--r--struct.c6
4 files changed, 19 insertions, 7 deletions
diff --git a/args.h b/args.h
index e023e290..d2d87de4 100644
--- a/args.h
+++ b/args.h
@@ -30,7 +30,7 @@ struct args {
cnum argc;
cnum fill;
val list;
- val arg[1];
+ val arg[FLEX_ARRAY];
};
typedef int arg_index;
@@ -38,6 +38,12 @@ typedef int arg_index;
#define ARGS_MAX 32
#define ARGS_MIN 4
+#if FLEX_ARRAY + 0 == 1
+#define ARGS_ABS_MIN 1
+#else
+#define ARGS_ABS_MIN 0
+#endif
+
struct args_bool_key {
val key;
val arg_p;
diff --git a/ffi.c b/ffi.c
index 6cbfe8c8..efd6cd42 100644
--- a/ffi.c
+++ b/ffi.c
@@ -2300,7 +2300,7 @@ static val ffi_struct_in(struct txr_ffi_type *tft, int copy, mem_t *src,
return strct;
if (strct == nil) {
- args_decl(args, 0);
+ args_decl(args, ARGS_ABS_MIN);
strct = make_struct(tft->lt, nil, args);
}
@@ -2367,7 +2367,7 @@ static val ffi_struct_get(struct txr_ffi_type *tft, mem_t *src, val self)
{
cnum i, nmemb = tft->nelem;
struct smemb *memb = tft->memb;
- args_decl(args, 0);
+ args_decl(args, ARGS_ABS_MIN);
val strct = make_struct(tft->lt, nil, args);
int flexp = tft->flexible;
@@ -6485,7 +6485,7 @@ val make_zstruct(val type, struct args *args)
val self = lit("make-zstruct");
struct txr_ffi_type *tft = ffi_type_struct_checked(self, type);
val pairs = args_get_list(args);
- args_decl(ms_args, 0);
+ args_decl(ms_args, ARGS_ABS_MIN);
val strct = make_struct(tft->lt, nil, ms_args);
mem_t *zbuf;
char *inited = coerce(char *, zalloca(tft->nelem));
diff --git a/lib.h b/lib.h
index 75aed65a..f5b5ed42 100644
--- a/lib.h
+++ b/lib.h
@@ -46,6 +46,12 @@ typedef double_uintptr_t dbl_ucnum;
#define coerce(TYPE, EXPR) ((TYPE) (EXPR))
#endif
+#if __STDC_VERSION__ >= 199901L
+#define FLEX_ARRAY
+#else
+#define FLEX_ARRAY 1
+#endif
+
#define TAG_SHIFT 2
#define TAG_MASK ((convert(cnum, 1) << TAG_SHIFT) - 1)
#define TAG_PTR 0
diff --git a/struct.c b/struct.c
index 9fca97a3..004c66d1 100644
--- a/struct.c
+++ b/struct.c
@@ -846,13 +846,13 @@ val make_struct(val type, val plist, struct args *boa)
val struct_from_plist(val type, struct args *plist)
{
- args_decl(boa, 0);
+ args_decl(boa, ARGS_ABS_MIN);
return make_struct_impl(lit("struct-from-plist"), type, plist, boa);
}
val struct_from_args(val type, struct args *boa)
{
- args_decl(pargs, 0);
+ args_decl(pargs, ARGS_ABS_MIN);
return make_struct_impl(lit("struct-from-args"), type, pargs, boa);
}
@@ -933,7 +933,7 @@ val make_lazy_struct(val type, val argfun)
val make_struct_lit(val type, val plist)
{
- args_decl(args, 0);
+ args_decl(args, ARGS_ABS_MIN);
val strct;
if (opt_compat && opt_compat <= 154) {