]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
manual: Fix missing includes in the mbstouwcs example.
authorCollin Funk <collin.funk1@gmail.com>
Sun, 28 Sep 2025 21:59:36 +0000 (14:59 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Tue, 30 Sep 2025 00:01:54 +0000 (17:01 -0700)
Previously this file would fail to compile with the following error:

    $ gcc manual/examples/mbstouwcs.c
    manual/examples/mbstouwcs.c: In function ‘mbstouwcs’:
    manual/examples/mbstouwcs.c:34:11: error: ‘errno’ undeclared (first use in this function)
       34 |           errno = EILSEQ;
          |           ^~~~~
    manual/examples/mbstouwcs.c:5:1: note: ‘errno’ is defined in header ‘<errno.h>’; this is probably fixable by adding ‘#include <errno.h>’
        4 | #include <wchar.h>
      +++ |+#include <errno.h>
        5 |
    manual/examples/mbstouwcs.c:34:11: note: each undeclared identifier is reported only once for each function it appears in
       34 |           errno = EILSEQ;
          |           ^~~~~
    manual/examples/mbstouwcs.c:34:19: error: ‘EILSEQ’ undeclared (first use in this function)
       34 |           errno = EILSEQ;
          |                   ^~~~~~
    manual/examples/mbstouwcs.c:47:20: error: implicit declaration of function ‘towupper’ [-Wimplicit-function-declaration]
       47 |           *wcp++ = towupper (wc);
          |                    ^~~~~~~~
    manual/examples/mbstouwcs.c:5:1: note: include ‘<wctype.h>’ or provide a declaration of ‘towupper’
        4 | #include <wchar.h>
      +++ |+#include <wctype.h>
        5 |
    manual/examples/mbstouwcs.c:47:20: warning: incompatible implicit declaration of built-in function ‘towupper’ [-Wbuiltin-declaration-mismatch]
       47 |           *wcp++ = towupper (wc);
          |                    ^~~~~~~~
    manual/examples/mbstouwcs.c:47:20: note: include ‘<wctype.h>’ or provide a declaration of ‘towupper’

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
manual/examples/mbstouwcs.c

index c94e1fa7900f7782db0a7e10326c2abd55327cf0..c492f37ef212f0edb8593032999c21470b289842 100644 (file)
@@ -1,7 +1,9 @@
+#include <errno.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 #include <wchar.h>
+#include <wctype.h>
 
 /* Do not include the above headers in the example.
 */