use 0 (configurable) for the C++ size of flexible arrays (fixes #808)

This commit is contained in:
Alex Shinn 2022-01-09 21:29:00 +09:00
parent 4d45583637
commit a127a332ac
2 changed files with 11 additions and 2 deletions

View file

@ -324,6 +324,15 @@
#define SEXP_MAX_ANALYZE_DEPTH 8192
#endif
/* The size of flexible arrays (empty arrays at the end of a struct */
/* representing the trailing data), when compiled with C++. Technically */
/* 0 is an illegal value here, and the C++ idiom is to use 1, but this */
/* breaks compatibility with C when computing the size of structs, and */
/* in practice all of the major C++ compilers support 0. */
#ifndef SEXP_FLEXIBLE_ARRAY_SIZE
#define SEXP_FLEXIBLE_ARRAY_SIZE 0
#endif
/************************************************************************/
/* DEFAULTS - DO NOT MODIFY ANYTHING BELOW THIS LINE */
/************************************************************************/

View file

@ -1,5 +1,5 @@
/* sexp.h -- header for sexp library */
/* Copyright (c) 2009-2015 Alex Shinn. All rights reserved. */
/* Copyright (c) 2009-2022 Alex Shinn. All rights reserved. */
/* BSD-style license: http://synthcode.com/license.txt */
#ifndef SEXP_H
@ -7,7 +7,7 @@
#ifdef __cplusplus
extern "C" {
#define SEXP_FLEXIBLE_ARRAY [1]
#define SEXP_FLEXIBLE_ARRAY [SEXP_FLEXIBLE_ARRAY_SIZE]
#else
#define SEXP_FLEXIBLE_ARRAY []
#endif