summaryrefslogtreecommitdiff
blob: da4d5c399aee034e6db16814868f6603ea112e4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
https://github.com/flightaware/tclx/pull/15

From a65705e6cba4fe395afbdc8c903b8b819d7e6962 Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Fri, 18 Nov 2022 01:12:17 +0000
Subject: [PATCH] Fix configure.ac compatibility with Clang 16

Clang 16 makes -Wimplicit-function-declaration and -Wimplicit-int errors by default.

Unfortunately, this can lead to misconfiguration or miscompilation of software as configure
tests may then return the wrong result.

We also fix -Wstrict-prototypes while here as it's easy to do and it prepares
us for C23.

For more information, see LWN.net [0] or LLVM's Discourse [1], the Gentoo wiki [2],
or the (new) c-std-porting mailing list [3].

[0] https://lwn.net/Articles/913505/
[1] https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror-implicit-function-declaration/65213
[2] https://wiki.gentoo.org/wiki/Modern_C_porting
[3] hosted at lists.linux.dev.

Bug: https://bugs.gentoo.org/881713
Signed-off-by: Sam James <sam@gentoo.org>
--- a/configure.in
+++ b/configure.in
@@ -193,10 +193,11 @@ WIFEXITED(x);	/* Generates compiler error if WIFEXITED uses an int. */
     
     AC_MSG_CHECKING(checking to see what 'times' returns)
     AC_TRY_RUN([
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/times.h>
 #include <unistd.h>
-main() {
+int main(void) {
     struct tms cpu;
     times(&cpu);
     sleep(2);
@@ -269,7 +270,8 @@ main() {
     
     AC_CHECK_FUNC(catgets,
     	[AC_MSG_CHECKING([catclose return value])
-    	 AC_TRY_COMPILE([#include <nl_types.h>], [
+    	 AC_TRY_COMPILE([#include <stdlib.h>
+         #include <nl_types.h>], [
     	    if (catclose ((nl_catd) 0) == 0) exit (0);],
     	    AC_MSG_RESULT(ok), [
     	    AC_MSG_RESULT([broken catclose return type])
--- a/tclconfig/tcl.m4
+++ b/tclconfig/tcl.m4
@@ -2525,7 +2525,8 @@ AC_DEFUN([TEA_TIME_HANDLER], [
     # (like convex) have timezone functions, etc.
     #
     AC_CACHE_CHECK([long timezone variable], tcl_cv_timezone_long, [
-	AC_TRY_COMPILE([#include <time.h>],
+	AC_TRY_COMPILE([#include <stdlib.h>
+            #include <time.h>],
 	    [extern long timezone;
 	    timezone += 1;
 	    exit (0);],
@@ -2537,7 +2538,8 @@ AC_DEFUN([TEA_TIME_HANDLER], [
 	# On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
 	#
 	AC_CACHE_CHECK([time_t timezone variable], tcl_cv_timezone_time, [
-	    AC_TRY_COMPILE([#include <time.h>],
+	    AC_TRY_COMPILE([#include <stdlib.h>
+                #include <time.h>],
 		[extern time_t timezone;
 		timezone += 1;
 		exit (0);],
@@ -2574,7 +2576,7 @@ AC_DEFUN([TEA_BUGGY_STRTOD], [
 	    AC_TRY_RUN([
 		#include <stdlib.h>
 		extern double strtod();
-		int main() {
+		int main(void) {
 		    char *infString="Inf", *nanString="NaN", *spaceString=" ";
 		    char *term;
 		    double value;