From 6722611bf848bcae11598e80f648c126192992c3 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Mon, 27 Nov 2023 14:59:05 +0100 Subject: [PATCH] procevent plugin: Disable the `-Wgnu-variable-sized-type-not-at-end` warning. --- src/procevent.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/procevent.c b/src/procevent.c index 03d9081f3..81a1c973f 100644 --- a/src/procevent.c +++ b/src/procevent.c @@ -101,6 +101,22 @@ #define PROCEVENT_VF_STATUS_CRITICAL_VALUE "Ready to terminate" #define PROCEVENT_VF_STATUS_NORMAL_VALUE "Active" +/* + * Disable a clang warning about variable sized types in the middle of a struct. + * + * The below code uses temporary structs containing a `struct cn_msg` followed + * by another field. `struct cn_msg` includes a "flexible array member" and the + * struct is an elegant and convenient way of populating this "flexible" element + * via the other field in the temporary struct. + * + * Unfortunately, this is not supported by the C standard. GCC and clang both + * can deal with the situation though. Disable the warning to keep the well + * readable code. + */ +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wgnu-variable-sized-type-not-at-end" +#endif + /* * Private data types */ -- 2.47.2