[PATCH 06/13] manual: Allow getsubopt example to compile with GCC 15.
Sam James
sam@gentoo.org
Tue Sep 30 00:18:11 GMT 2025
Collin Funk <collin.funk1@gmail.com> writes:
> GCC 15 turned -Wincompatible-pointer-types into a compiler error instead
> of a warning by default. This patch prevents the following error:
We made those changes in GCC 14. What did change in 15 is that you see
this "more often" because we changed the default -std= to gnu23. But
that doesn't apply here.
>
> $ gcc manual/examples/subopt.c
> manual/examples/subopt.c: In function ‘main’:
> manual/examples/subopt.c:64:40: error: passing argument 2 of ‘getsubopt’ from incompatible pointer type [-Wincompatible-pointer-types]
> 64 | switch (getsubopt (&subopts, mount_opts, &value))
> | ^~~~~~~~~~
> | |
> | const char **
> In file included from manual/examples/subopt.c:19:
> /usr/include/stdlib.h:1100:47: note: expected ‘char * const* restrict’ but argument is of type ‘const char **’
> 1100 | char *const *__restrict __tokens,
> | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
> ---
> manual/examples/subopt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/manual/examples/subopt.c b/manual/examples/subopt.c
> index e7a073099a..63b5271483 100644
> --- a/manual/examples/subopt.c
> +++ b/manual/examples/subopt.c
> @@ -61,7 +61,7 @@ main (int argc, char **argv)
> case 'o':
> subopts = optarg;
> while (*subopts != '\0')
> - switch (getsubopt (&subopts, mount_opts, &value))
> + switch (getsubopt (&subopts, (char * const *) mount_opts, &value))
> {
> case RO_OPTION:
> read_only = 1;
More information about the Libc-alpha
mailing list