autoconf-patches
[Top][All Lists]
Advanced

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

Re: [PATCH v2] specify void prototype for functions with no parameters


From: Khem Raj
Subject: Re: [PATCH v2] specify void prototype for functions with no parameters
Date: Thu, 1 Sep 2022 09:53:44 -0700
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.0

On 8/30/22 2:53 PM, Paul Eggert wrote:
On 8/29/22 21:35, Khem Raj wrote:
Compilers defaulting to C99 flag such functions as warning which fails
to compile when using -Werror

As mentioned earlier, projects should not use -Werror when configuring, for several reasons (this is just one). After you mentioned rsync was using something like -Werror I sent in a patch to the rsync folks, and rsync has been fixed:

https://github.com/WayneD/rsync/commit/9a3449a3980421f84ac55498ba565bc112b20d6c

What other projects are doing it? They should be fixed too, regardless of whether we change Autoconf here.

As for Autoconf, if we're going to make this change at all, we should do it fully. Something like the attached patch, perhaps. I haven't installed it.

Thanks, I tried this patch over mine and I ran into few problems. Some of them were latent issues[1] but some are problems[2] especially using AC_CHECK_FUNCS when default compiler is C++ compiler not C compiler

A code snippet like below it generated

#include <limits.h>
#undef pipe

/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply.  */
char pipe (int);
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS.  Some functions are actually named
something starting with __ and the normal name is an alias.  */
#if defined __stub_pipe || defined __stub___pipe
choke me
#endif

int
main (void)
{
return pipe (0);
;
return 0;
}


When this is compiled with C compiler it links fine, however when using C++ compiler this fails to link

% cc a.c

% c++ a.c
/usr/bin/ld: /tmp/ccRkgy7K.o: in function `main':
a.c:(.text+0xa): undefined reference to `pipe(int)'
collect2: error: ld returned 1 exit status

[1] https://gitlab.xfce.org/xfce/xfce4-dev-tools/-/issues/57
[2] https://errors.yoctoproject.org/Errors/Details/671040/

Attachment: OpenPGP_0xBB053355919D3314.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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