bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] examples: hello-c: Include config.h if HAVE_CONFIG_H is defined


From: Marvin Schmidt
Subject: [PATCH] examples: hello-c: Include config.h if HAVE_CONFIG_H is defined
Date: Thu, 15 Sep 2022 14:45:11 +0200

Recent compilers are becoming stricter about missing function declarations and
the autopoint-3 test failed with clang-15 due to an implicit declaration of 
`getpid()`:

> x86_64-pc-linux-musl-cc -DLOCALEDIR=\"/usr/local/share/locale\" 
> -DHAVE_CONFIG_H -I.  -I. -I.   -march=native -O2 -pipe -MT hello.o -MD
> -MP -MF .deps/hello.Tpo -c -o hello.o hello.c
> hello.c:31:63: error: call to undeclared function 'getpid'; ISO C99 and later 
> do not support implicit function declarations [-Wimplicit
> -function-declaration]
>   printf (_("This program is running as process number %d."), getpid ());
>                                                               ^
> 1 error generated.

The `hello.c` source conditionally includes `<unistd.h>` when `HAVE_UNISTD_H`
is defined, but since `config.h` wasn't included the define was not present

Include `config.h` when `HAVE_CONFIG_H` is defined to fix this
---
 gettext-tools/examples/hello-c/hello.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gettext-tools/examples/hello-c/hello.c 
b/gettext-tools/examples/hello-c/hello.c
index 20be7f3b6668..0eacff5dac80 100644
--- a/gettext-tools/examples/hello-c/hello.c
+++ b/gettext-tools/examples/hello-c/hello.c
@@ -3,6 +3,9 @@
 
    Source code of the C program.  */
 
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
 
 /* Get setlocale() declaration.  */
 #include <locale.h>
-- 
2.37.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]