summaryrefslogtreecommitdiff
path: root/src/systemd/_sd-common.h
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-01-04 12:37:10 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-01-04 12:37:25 +0100
commit4199f6896aee4394bddfb85e45eabe34d60038cb (patch)
tree5c8b1f91631215cb4d83ddbdbe0f72f7437fb975 /src/systemd/_sd-common.h
parent3042bbebddb819371aa2ee0811a1f9d3d38f7b94 (diff)
downloadsystemd-4199f6896aee4394bddfb85e45eabe34d60038cb.tar.gz
Use c99 static array size declarations in exported functions too
It seems quite useful to provide this additional information in public exported functions. This is a c99 feature, not supported in C++. Without the check in _sd-common.h: FAILED: test-bus-vtable-cc@exe/src_libsystemd_sd-bus_test-bus-vtable-cc.cc.o ... In file included from ../src/libsystemd/sd-bus/test-bus-vtable-cc.cc:9: In file included from ../src/systemd/sd-bus-vtable.h:26: In file included from ../src/systemd/sd-bus.h:26: ../src/systemd/sd-id128.h:38:47: error: static array size is a C99 feature, not permitted in C++ char *sd_id128_to_string(sd_id128_t id, char s[static SD_ID128_STRING_MAX]); ^ In .c files, I opted to use the define for consistency, even though we don't support compilation with a C++ compiler, so the unconditional keyword would work too.
Diffstat (limited to 'src/systemd/_sd-common.h')
-rw-r--r--src/systemd/_sd-common.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/systemd/_sd-common.h b/src/systemd/_sd-common.h
index 05c38008cf..b3ee7bbc24 100644
--- a/src/systemd/_sd-common.h
+++ b/src/systemd/_sd-common.h
@@ -72,6 +72,14 @@ typedef void (*_sd_destroy_t)(void *userdata);
# endif
#endif
+#ifndef _SD_ARRAY_STATIC
+# if __STDC_VERSION__ >= 199901L
+# define _SD_ARRAY_STATIC static
+# else
+# define _SD_ARRAY_STATIC
+# endif
+#endif
+
#define _SD_DEFINE_POINTER_CLEANUP_FUNC(type, func) \
static __inline__ void func##p(type **p) { \
if (*p) \