summaryrefslogtreecommitdiff
path: root/dev-lang/php/files/php-8.1.27-implicit-decls.patch
blob: 443b02ba17c2124106fbab538caa882fd81ff8f3 (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
From 79df2b9dcbe0388667c832b2c702ca3158330ed7 Mon Sep 17 00:00:00 2001
From: Michael Orlitzky <michael@orlitzky.com>
Date: Mon, 4 Mar 2024 11:48:01 -0500
Subject: [PATCH] ext/iconv/config.m4: add missing stdio.h include.

The next generation of C compilers is going to enforce the C standard
more strictly:

  https://wiki.gentoo.org/wiki/Modern_C_porting

One warning that will eventually become an error is
-Wimplicit-function-declaration. This is relatively easy to catch in
most code (it will fail to compile), but inside of autoconf tests it
can go unnoticed because many feature-test compilations fail by
design. For example,

  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <iconv.h>]],
                 [[iconv_ccs_init(NULL, NULL);]])]...

is designed to fail if iconv_ccs_init() is not in iconv.h. On the
other hand,

  AC_RUN_IFELSE([AC_LANG_SOURCE([[
  #include <iconv.h>
  int main() {
    printf("%d", _libiconv_version);
    return 0;
  }

should pass if _libiconv_version is defined. If the user has
-Werror=implicit-function-declaration in his CFLAGS, however,
it will not:

  $ export CFLAGS="$CFLAGS -Werror=implicit-function-declaration"
  $ ./configure
  ...
  checking if using GNU libiconv... no

This is because the stdio.h header that defines printf() is missing:

  conftest.c:240:3: error: implicit declaration of function 'printf'
  [-Werror=implicit-function-declaration]
    240 |   printf("%d", _libiconv_version);
        |   ^~~~~~
  conftest.c:239:1: note: include '<stdio.h>' or provide a declaration
  of 'printf'

This commit adds the include, correcting the test with any compiler
that balks at implicit function definitions.

(Backport to php-8.1.27)

Closes GH-10751
---
 ext/iconv/config.m4 | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ext/iconv/config.m4 b/ext/iconv/config.m4
index ac57c81e..b8044bf2 100644
--- a/ext/iconv/config.m4
+++ b/ext/iconv/config.m4
@@ -30,6 +30,7 @@ if test "$PHP_ICONV" != "no"; then
       AC_MSG_CHECKING([if using GNU libiconv])
       AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <iconv.h>
+#include <stdio.h>
 int main() {
   printf("%d", _libiconv_version);
   return 0;
-- 
2.43.0