[php-src] master: ext/intl: don't include C++ ICU headers from C translation units (#22636)
Ondřej Surý via GitHub <[email protected]>
| Newsgroups | gmane.comp.php.cvs.general |
|---|---|
| Message-ID | <[email protected]> |
Author: Ondřej Surý (oerdnj)
Committer: GitHub (web-flow)
Pusher: LamentXU123
Date: 2026-07-08T17:27:30+08:00
Commit: https://github.com/php/php-src/commit/edcd94d5816ac072f34cd3a93f59905575bbfe39
Raw diff: https://github.com/php/php-src/commit/edcd94d5816ac072f34cd3a93f59905575bbfe39.diff
ext/intl: don't include C++ ICU headers from C translation units (#22636)
php_intl.c is compiled as C but transitively includes formatter_data.h and
listformatter_class.h, which (since 8.6) include <unicode/numfmt.h> and
<unicode/listformatter.h> unconditionally. On ICU >= 64 those C++ headers are
a no-op in a C compile, but ICU 63 (Debian Buster) has an unguarded
"#include <cstddef>" at the top of unistr.h, so the C compile fails with
"fatal error: cstddef: No such file or directory".
The C path only uses the "typedef void" shim (NumberFormat*/ListFormatter*
are just void*), so it needs no ICU header at all. Move the C++ include inside
the existing #ifdef __cplusplus guard. No-op on newer ICU.
Changed paths:
M ext/intl/formatter/formatter_data.h
M ext/intl/listformatter/listformatter_class.h
Diff:
diff --git a/ext/intl/formatter/formatter_data.h b/ext/intl/formatter/formatter_data.h
index 1208970471bf..46a82cb9bd0f 100644
--- a/ext/intl/formatter/formatter_data.h
+++ b/ext/intl/formatter/formatter_data.h
@@ -23,9 +23,8 @@ extern "C" {
}
#endif
-#include <unicode/numfmt.h>
-
#ifdef __cplusplus
+#include <unicode/numfmt.h>
using icu::NumberFormat;
#else
typedef void NumberFormat;
diff --git a/ext/intl/listformatter/listformatter_class.h b/ext/intl/listformatter/listformatter_class.h
index 7e7fd29207fc..bdf21b6886e0 100644
--- a/ext/intl/listformatter/listformatter_class.h
+++ b/ext/intl/listformatter/listformatter_class.h
@@ -21,9 +21,8 @@
#include "intl_error.h"
#include "intl_data.h"
-#include <unicode/listformatter.h>
-
#ifdef __cplusplus
+#include <unicode/listformatter.h>
using icu::ListFormatter;
#else
typedef void ListFormatter;