[PATCH 06/13] manual: Allow getsubopt example to compile with GCC 15.

Collin Funk collin.funk1@gmail.com
Sun Sep 28 22:45:59 GMT 2025


GCC 15 turned -Wincompatible-pointer-types into a compiler error instead
of a warning by default. This patch prevents the following error:

    $ 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;
-- 
2.51.0



More information about the Libc-alpha mailing list