Skip to content

Commit 660a860

Browse files
authored
Fix GH-15501: Windows HAVE_<header>_H macros defined to 1 or undefined (#15508)
Previously the CHECK_HEADER_ADD_INCLUDE function defined the `HAVE_<header>_H` preprocessor macros to value 0 or 1 whether the `<header.h>` file was found. This syncs it with Autotools build system where most of these macros are either undefined or defined to 1. In possible edge cases where such macros might be intentionally used like this without being aware that HAVE_HEADER_H can be 0 or 1 on Windows: | #ifdef HAVE_HEADER_H | ... | #endif there is backwards incompatibility for PECL extensions in case the header wouldn't exist on Windows such code wouldn't execute. However, this is considered a bug if such case is present. From the Autotools point of view, the check is correct though and should be used with ifdef/defined() checks. Help text is also synced to Autotools style: `Define to 1 if you have the <header.h> header file.`
1 parent 327588a commit 660a860

File tree

7 files changed

+19
-14
lines changed

7 files changed

+19
-14
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ PHP NEWS
1212
. Fixed bug GH-15187 (Various hooked object iterator issues). (ilutov)
1313
. Fixed bug GH-15456 (Crash in get_class_vars() on virtual properties).
1414
(ilutov)
15+
. Fixed bug GH-15501 (Windows HAVE_<header>_H macros defined to 1 or
16+
undefined). (Peter Kokot)
1517

1618
- MySQLnd:
1719
. Fixed bug GH-15432 (Heap corruption when querying a vector). (cmb,

UPGRADING.INTERNALS

+3
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ PHP 8.4 INTERNALS UPGRADE NOTES
230230
- Added configure option --enable-phpdbg-debug to build phpdbg in debug mode.
231231
- The win32/build/libs_version.txt file has been removed.
232232
- MSVC builds now use the new preprocessor (/Zc:preprocessor).
233+
- The CHECK_HEADER_ADD_INCLUDE function now consistently defines preprocessor
234+
macros HAVE_<header>_H either to value 1 or leaves them undefined to match
235+
the Autotools headers checks.
233236

234237
========================
235238
3. Module changes

ext/com_dotnet/com_dotnet.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include "php.h"
2222

23-
#if HAVE_MSCOREE_H
23+
#ifdef HAVE_MSCOREE_H
2424
# include "php_ini.h"
2525
# include "ext/standard/info.h"
2626
# include "php_com_dotnet.h"

ext/com_dotnet/com_extension.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ PHP_MINIT_FUNCTION(com_dotnet)
195195
tmp->create_object = php_com_object_new;
196196
tmp->get_iterator = php_com_iter_get;
197197

198-
#if HAVE_MSCOREE_H
198+
#ifdef HAVE_MSCOREE_H
199199
tmp = register_class_dotnet(php_com_variant_class_entry);
200200
tmp->default_object_handlers = &php_com_object_handlers;
201201
tmp->create_object = php_com_object_new;
@@ -216,7 +216,7 @@ PHP_MINIT_FUNCTION(com_dotnet)
216216
PHP_MSHUTDOWN_FUNCTION(com_dotnet)
217217
{
218218
UNREGISTER_INI_ENTRIES();
219-
#if HAVE_MSCOREE_H
219+
#ifdef HAVE_MSCOREE_H
220220
if (COMG(dotnet_runtime_stuff)) {
221221
php_com_dotnet_mshutdown();
222222
}
@@ -239,7 +239,7 @@ PHP_RINIT_FUNCTION(com_dotnet)
239239
/* {{{ PHP_RSHUTDOWN_FUNCTION */
240240
PHP_RSHUTDOWN_FUNCTION(com_dotnet)
241241
{
242-
#if HAVE_MSCOREE_H
242+
#ifdef HAVE_MSCOREE_H
243243
if (COMG(dotnet_runtime_stuff)) {
244244
php_com_dotnet_rshutdown();
245245
}
@@ -257,7 +257,7 @@ PHP_MINFO_FUNCTION(com_dotnet)
257257
php_info_print_table_row(2, "COM support", "enabled");
258258
php_info_print_table_row(2, "DCOM support", COMG(allow_dcom) ? "enabled" : "disabled");
259259

260-
#if HAVE_MSCOREE_H
260+
#ifdef HAVE_MSCOREE_H
261261
php_info_print_table_row(2, ".Net support", "enabled");
262262
#else
263263
php_info_print_table_row(2, ".Net support", "not present in this build");

ext/com_dotnet/com_extension.stub.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ class com extends variant
363363
public function __construct(string $module_name, array|string|null $server_name = null, int $codepage = CP_ACP, string $typelib = "") {}
364364
}
365365

366-
#if HAVE_MSCOREE_H
366+
#ifdef HAVE_MSCOREE_H
367367
class dotnet extends variant
368368
{
369369
public function __construct(string $assembly_name, string $datatype_name, int $codepage = CP_ACP) {}

ext/com_dotnet/com_extension_arginfo.h

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

win32/build/confutils.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1040,10 +1040,10 @@ function CHECK_HEADER_ADD_INCLUDE(header_name, flag_name, path_to_check, use_env
10401040
add_to_flag_only = true;
10411041
}
10421042

1043-
if (typeof(add_to_flag_only) != "undefined") {
1043+
if (typeof(add_to_flag_only) != "undefined" && have) {
10441044
ADD_FLAG(flag_name, "/DHAVE_" + sym + "=" + have);
1045-
} else if (!configure_hdr.Exists('HAVE_' + sym)) {
1046-
AC_DEFINE("HAVE_" + sym, have, "have the " + header_name + " header file");
1045+
} else if (!configure_hdr.Exists('HAVE_' + sym) && have) {
1046+
AC_DEFINE("HAVE_" + sym, have, "Define to 1 if you have the <" + header_name + "> header file.");
10471047
}
10481048

10491049
return p;

0 commit comments

Comments
 (0)