Skip to content

fix(rar): undef PARSE_SERVER before unrar includes on Windows - #1268

Merged
crazywhalecc merged 1 commit into
v3from
fix/windows-rar-parse-server
Oct 22, 2026
Merged

crazywhalecc merged 1 commit into
v3from
fix/windows-rar-parse-server

Conversation

@crazywhalecc

Copy link
Copy Markdown
Owner

Follow-up to #1263. The Windows spc-max jobs still fail at urlmon.h after the WINVER guard, because the real collision is a macro name.

Root cause

unrar/os.hpp includes <shlwapi.h>, and the Windows SDK chain is:

shlwapi.h -> objbase.h -> urlmon.h

urlmon.h declares:

PARSE_SERVER = ( PARSE_MIME + 1 ),

But main/php_variables.h already defines:

#define PARSE_SERVER 5

main/internal_functions.c includes php.h first and then ext/rar/php_rar.h (which includes unrar/os.hpp), so the enum member expands to 5 = (PARSE_MIME + 1) and MSVC reports:

urlmon.h(6694): error C2059: syntax error: 'constant'
urlmon.h(6803): error C2146: syntax error: missing ')' before identifier 'ParseAction'

The WINVER guard from #1263 removes the C4005 warnings but does not fix this; the failure is PARSE_SERVER, not WINVER.

Fix

In php_rar.h, #undef PARSE_SERVER before #include "unrar/os.hpp". The rar extension does not use that macro, so the undef is TU-local.

Validation

  • php -l, composer test (468), composer analyse, composer cs-fix: clean.
  • Windows rar ext test will verify the MSVC build; cannot run MSVC locally (macOS host).

unrar os.hpp includes shlwapi.h, which includes objbase.h -> urlmon.h.
urlmon.h declares a PARSEACTION enum member called PARSE_SERVER, but
main/php_variables.h already defines PARSE_SERVER as 5. In the generated
main/internal_functions.c this expands to "5 = (PARSE_MIME + 1)" and
MSVC fails with C2059 at urlmon.h.

Undefine PARSE_SERVER in php_rar.h before including unrar/os.hpp. The
header is not used by the rar extension, so this is TU-local.

The WINVER guard is kept (it silences the SDK macro redefinition
warnings), but it was not the cause of the urlmon.h failure.
@crazywhalecc crazywhalecc added the need-test This PR has not been tested yet, cannot merge now label Oct 22, 2026
@github-actions

Copy link
Copy Markdown

StaticPHP Test Bot

Detected: Extensions: rar | Libraries: none | Targets: none
Active labels: none
Available labels: need-test (gate), test/linux test/windows test/macos (platform), test/tier2 (extra arch), test/php-83 test/php-84 (PHP version), sapi/frankenphp (extra FrankenPHP SAPI build)
Config: Linux x86_64 + Windows x86_64 + macOS arm64 | PHP 8.5 NTS

@crazywhalecc
crazywhalecc merged commit d7f1a88 into v3 Oct 22, 2026
11 of 18 checks passed
@crazywhalecc
crazywhalecc deleted the fix/windows-rar-parse-server branch October 22, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need-test This PR has not been tested yet, cannot merge now

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants