From c6d6720c3026efb74092c021a06f8f2c6d36fb67 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 7 Jan 2025 11:15:25 -0500 Subject: build: Check for compound literal storage-class support This lets us use them on GCC >= 13, even before C23. --- build/has/compound-literal-storage.c | 6 ++++++ build/header.mk | 1 + src/diag.h | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 build/has/compound-literal-storage.c diff --git a/build/has/compound-literal-storage.c b/build/has/compound-literal-storage.c new file mode 100644 index 0000000..e2281e1 --- /dev/null +++ b/build/has/compound-literal-storage.c @@ -0,0 +1,6 @@ +// Copyright © Tavian Barnes +// SPDX-License-Identifier: 0BSD + +int main(void) { + return (static int){0}; +} diff --git a/build/header.mk b/build/header.mk index 8b697d6..919a2a2 100644 --- a/build/header.mk +++ b/build/header.mk @@ -19,6 +19,7 @@ HEADERS := \ gen/has/acl-is-trivial-np.h \ gen/has/acl-trivial.h \ gen/has/builtin-riscv-pause.h \ + gen/has/compound-literal-storage.h \ gen/has/confstr.h \ gen/has/extattr-get-file.h \ gen/has/extattr-get-link.h \ diff --git a/src/diag.h b/src/diag.h index 3bea9b2..7b3e8a5 100644 --- a/src/diag.h +++ b/src/diag.h @@ -27,7 +27,7 @@ struct bfs_loc { /** * Get the current source code location. */ -#if __STDC_VERSION__ >= C23 +#if BFS_HAS_COMPOUND_LITERAL_STORAGE # define bfs_location() (&(static const struct bfs_loc)BFS_LOC_INIT) #else # define bfs_location() (&(const struct bfs_loc)BFS_LOC_INIT) -- cgit v1.2.3