]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
manual: Fix missing declaration in strdupa example.
authorCollin Funk <collin.funk1@gmail.com>
Sun, 28 Sep 2025 22:17:17 +0000 (15:17 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Tue, 30 Sep 2025 00:01:54 +0000 (17:01 -0700)
Without _GNU_SOURCE defined this file fails to compile with the
following error:

    $ gcc manual/examples/strdupa.c
    manual/examples/strdupa.c: In function ‘main’:
    manual/examples/strdupa.c:27:19: error: implicit declaration of function ‘strdupa’; did you mean ‘strdup’? [-Wimplicit-function-declaration]
       27 |   char *wr_path = strdupa (path);
          |                   ^~~~~~~
          |                   strdup
    manual/examples/strdupa.c:27:19: error: initialization of ‘char *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]

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

index 7fd2293d9f71063ad2d2c57eaf9c1503b5f57cc4..004a3b3d7c9eaa3fd7e53b4a7a676af1c5f8317f 100644 (file)
@@ -15,6 +15,7 @@
    along with this program; if not, see <https://www.gnu.org/licenses/>.
 */
 
+#define _GNU_SOURCE 1
 #include <paths.h>
 #include <string.h>
 #include <stdio.h>