From 9823703ae6ce92c345b6a9bd4a68889bfbc75dd4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 11 Feb 2021 16:02:59 +0100 Subject: [PATCH] sd-common: add new macro for forcing 64bit size for public enums That's the only way we can retain type-safe enums while being able to guarantee for stable enum sizes. --- src/systemd/_sd-common.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/systemd/_sd-common.h b/src/systemd/_sd-common.h index e3de2ae5629..e121429640b 100644 --- a/src/systemd/_sd-common.h +++ b/src/systemd/_sd-common.h @@ -99,4 +99,10 @@ typedef void (*_sd_destroy_t)(void *userdata); } \ struct _sd_useless_struct_to_allow_trailing_semicolon_ +/* The following macro should be used in all public enums, to force 64bit wideness on them, so that we can + * freely extend them later on, without breaking compatibility. */ +#define _SD_ENUM_FORCE_S64(id) \ + _SD_##id##_INT64_MIN = INT64_MIN, \ + _SD_##id##_INT64_MAX = INT64_MAX + #endif -- 2.47.3