[Top][All Lists]

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

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

From: Bruno Haible
Subject: Re: [PATCH] examples: hello-c: Include config.h if HAVE_CONFIG_H is defined
Date: Fri, 16 Sep 2022 00:07:43 +0200

Marvin Schmidt wrote:
> 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

What you describe is true if the configure.ac file would contain an

But in the distributed sample the configure.ac file does not contain
an AC_CONFIG_HEADER or AC_CONFIG_HEADERS invocation. Therefore no
config.h is generated; instead, all -D options are part of the compiler

When you start with that example and add an AC_CONFIG_HEADERS([config.h]),
then yes you need a '#include <config.h>' in each *.c source file.


reply via email to

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