From 94ad70989f843a8dd7f936769fe6ba2e06a16992 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 4 Apr 2024 02:25:57 +0900 Subject: [PATCH] man/example: also build example code with C90 Unfortunately, sd-bus-vtable.h, sd-journal.h, and sd-id128.h have variadic macro and inline initialization of sub-object, these are not supported in C90. So, we need to silence some errors. --- man/logcontrol-example.c | 6 ++++-- man/meson.build | 2 ++ man/sd-bus-container-append.c | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/man/logcontrol-example.c b/man/logcontrol-example.c index 8c45369fc3b..23e73846cdb 100644 --- a/man/logcontrol-example.c +++ b/man/logcontrol-example.c @@ -124,7 +124,8 @@ static int property_set( return r; if (strcmp(property, "LogLevel") == 0) { - for (int i = 0; i < LOG_DEBUG + 1; i++) + int i; + for (i = 0; i < LOG_DEBUG + 1; i++) if (strcmp(value, log_level_table[i]) == 0) { o->log_level = i; setlogmask(LOG_UPTO(i)); @@ -138,7 +139,8 @@ static int property_set( } if (strcmp(property, "LogTarget") == 0) { - for (LogTarget i = 0; i < _LOG_TARGET_MAX; i++) + LogTarget i; + for (i = 0; i < _LOG_TARGET_MAX; i++) if (strcmp(value, log_target_table[i]) == 0) { o->log_target = i; return 0; diff --git a/man/meson.build b/man/meson.build index a728fa33842..69ea5c403ec 100644 --- a/man/meson.build +++ b/man/meson.build @@ -306,10 +306,12 @@ default_args = [ ] std_args_in = [ + [ '-std=c90', '-Wno-pedantic', '-Wno-variadic-macros', ], [ '-std=c99', ], [ '-std=c11', ], [ '-std=c17', ], [ '-std=c23', ], + [ '-std=gnu90', '-Wno-pedantic', '-Wno-variadic-macros', ], [ '-std=gnu99', ], [ '-std=gnu11', ], [ '-std=gnu17', ], diff --git a/man/sd-bus-container-append.c b/man/sd-bus-container-append.c index 8bb4f33e867..07a24f24cc6 100644 --- a/man/sd-bus-container-append.c +++ b/man/sd-bus-container-append.c @@ -3,13 +3,14 @@ #include int append_strings_to_message(sd_bus_message *m, const char *const *arr) { + const char *s; int r; r = sd_bus_message_open_container(m, 'a', "s"); if (r < 0) return r; - for (const char *s = *arr; *s; s++) { + for (s = *arr; *s; s++) { r = sd_bus_message_append(m, "s", s); if (r < 0) return r;