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.
This commit is contained in:
Yu Watanabe 2024-04-04 02:25:57 +09:00
parent 56e6bf9e04
commit 94ad70989f
3 changed files with 8 additions and 3 deletions

View file

@ -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;

View file

@ -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', ],

View file

@ -3,13 +3,14 @@
#include <systemd/sd-bus.h>
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;