Skip to content

Declare yaml_get_max_nest_level with (void) - #362

Open
th-in-gs wants to merge 1 commit into
yaml:masterfrom
th-in-gs:fix-nest-level-getter-prototype
Open

th-in-gs wants to merge 1 commit into
yaml:masterfrom
th-in-gs:fix-nest-level-getter-prototype

Conversation

@th-in-gs

Copy link
Copy Markdown

yaml_get_max_nest_level(), introduced in #335, was declared and defined with an empty parameter list (()). Before C23 that declares a function without a prototype, which is obsolescent and is diagnosed by -Wstrict-prototypes, and by -Wmissing-prototypes at the definition (an empty list is not a prototype that can precede it).

In C23, () is equivalent to (void), so there is no problem compiling for C23. But older clients that include yaml.h with those warnings enabled and treated as errors fail to compile.

This change uses (void) in both places, as the other zero-argument functions in yaml.h do. The meaning is unchanged, and in C23 () and (void) are equivalent, so there is no drawback to this (indeed, it arguably makes it match project style even for C23).

With the change, compiling src/*.c with -Wall -Wstrict-prototypes -Wmissing-prototypes gives no warnings as far back as C89.

yaml_get_max_nest_level(), introduced in yaml#335, was declared and defined
with an empty parameter list. Before C23 that declares a function
without a prototype, which is obsolescent and is diagnosed by
-Wstrict-prototypes, and by -Wmissing-prototypes at the definition (an
empty list is not a prototype that can precede it). Code that includes
yaml.h with those warnings enabled, and treated as errors, fails to
compile.

Use (void) in both places, as the other zero-argument functions in
yaml.h do. The meaning is unchanged, and in C23 () and (void) are
equivalent.

This is the only empty parameter list in include/ and src/. With the
change, compiling src/*.c with -Wall -Wstrict-prototypes
-Wmissing-prototypes gives no warnings under gnu99, gnu17 and gnu23.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant