Re: [PATCH] AC_LANG_INT_SAVE: Modernize function declarators (C89 and above).

Paul Eggert <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.patches
Organization UCLA Computer Science Department
Message-ID <[email protected]>
On 8/6/20 4:25 PM, Vincent Lefevre wrote:
> IMHO, in the mean time, a "void" for the parameter list should be
> used when it makes sense.

For what it's worth, I count 13 instances of 'int main (void) { ... }' in Gnulib 
code, and 136 instances of 'int main () { ... }'. As I recall, the latter is for 
C++ compatibility, which I guess is not an issue with MPFR.

It's not a big deal either way, but if it helps MPFR out I suppose it's a win. I 
installed the attached two patches. The first one fixes the problem you 
mentioned, along with a similar issue in the 'inline' detection. The second one 
fixes a related problem with 'int main (int argc)'.
0001-Pacify-Werror-in-two-places.patch (text/x-patch, 1.6 KB)
From d3f54e6d5ca216594a8550c1404762a5b8f2ecec Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Thu, 6 Aug 2020 17:37:42 -0700
Subject: [PATCH 1/2] Pacify -Werror in two places
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Although this cannot easily be done in general, there are a couple
of places where it’s easy.
* lib/autoconf/c.m4 (AC_LANG_INT_SAVE (C)):
Change ‘()’ to ‘(void)’ to pacify picky compilers.
Problem reported by Vincent Lefevre in:
https://lists.gnu.org/r/autoconf-patches/2020-08/msg00000.html
(AC_C_INLINE): Likewise.
---
 lib/autoconf/c.m4 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index 0027f98b..eaef13a9 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -194,8 +194,8 @@ return test_array @<:@0@:>@;
 # But we include them only after the EXPRESSION has been evaluated.
 m4_define([AC_LANG_INT_SAVE(C)],
 [AC_LANG_PROGRAM([$1
-static long int longval () { return $2; }
-static unsigned long int ulongval () { return $2; }
+static long int longval (void) { return $2; }
+static unsigned long int ulongval (void) { return $2; }
 @%:@include <stdio.h>
 @%:@include <stdlib.h>],
 [
@@ -1747,8 +1747,8 @@ for ac_kw in inline __inline__ __inline; do
   AC_COMPILE_IFELSE([AC_LANG_SOURCE(
 [#ifndef __cplusplus
 typedef int foo_t;
-static $ac_kw foo_t static_foo () {return 0; }
-$ac_kw foo_t foo () {return 0; }
+static $ac_kw foo_t static_foo (void) {return 0; }
+$ac_kw foo_t foo (void) {return 0; }
 #endif
 ])],
 		    [ac_cv_c_inline=$ac_kw])
-- 
2.17.1
0002-Avoid-one-argument-main.patch (text/x-patch, 1.1 KB)
From 38219077b2d677607cb3d7de12c54085d578a99c Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Thu, 6 Aug 2020 17:40:49 -0700
Subject: [PATCH 2/2] =?UTF-8?q?Avoid=20one-argument=20=E2=80=98main?=
 =?UTF-8?q?=E2=80=99?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* tests/autotest.at (C unit tests, C unit tests (EXEEXT)):
Avoid ‘int main (int argc)’ as the C standard says this
is not portable.
---
 tests/autotest.at | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/autotest.at b/tests/autotest.at
index dbd86460..5519e9c7 100644
--- a/tests/autotest.at
+++ b/tests/autotest.at
@@ -1904,7 +1904,7 @@ AC_OUTPUT
 
 # Test file
 AT_DATA([testprog.c],
-[[int main(int argc) { return argc == 2 ? 0 : 1; }
+[[int main (int argc, char **argv) { return argc == 2 ? 0 : 1; }
 ]])
 
 # Testsuite
@@ -1956,7 +1956,7 @@ AC_OUTPUT
 
 # Test file
 AT_DATA([testprog.c],
-[[int main(int argc) { return argc == 2 ? 0 : 1; }
+[[int main (int argc, char **argv) { return argc == 2 ? 0 : 1; }
 ]])
 
 # Testsuite
-- 
2.17.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.