Skip to content

Commit 105f032

Browse files
dunglasclaude
andcommitted
fix(xlswriter): convert K&R function declaration to ANSI C in bundled minizip
The bundled minizip in xlswriter (pinned at libxlsxwriter RELEASE_1.0.0) uses a K&R-style function declaration in mztools.c. Modern Clang on macOS (defaulting to C23) rejects this as a hard syntax error since K&R declarations were removed from the C23 standard. The upstream libxlsxwriter has already fixed this on their main branch. This patch applies the same fix during the build process. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d411fac commit 105f032

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/SPC/builder/extension/xlswriter.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace SPC\builder\extension;
66

77
use SPC\builder\Extension;
8+
use SPC\store\FileSystem;
89
use SPC\store\SourcePatcher;
910
use SPC\util\CustomExt;
1011

@@ -28,6 +29,18 @@ public function getWindowsConfigureArg(bool $shared = false): string
2829
public function patchBeforeMake(): bool
2930
{
3031
$patched = parent::patchBeforeMake();
32+
33+
// Fix K&R C function declaration in bundled minizip rejected by modern Clang (C23 default)
34+
$mztools = $this->source_dir . '/library/libxlsxwriter/third_party/minizip/mztools.c';
35+
if (file_exists($mztools)) {
36+
FileSystem::replaceFileStr(
37+
$mztools,
38+
"extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)\nconst char* file;\nconst char* fileOut;\nconst char* fileOutTmp;\nuLong* nRecovered;\nuLong* bytesRecovered;\n{",
39+
"extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered)\n{"
40+
);
41+
$patched = true;
42+
}
43+
3144
if (PHP_OS_FAMILY === 'Windows') {
3245
// fix windows build with openssl extension duplicate symbol bug
3346
SourcePatcher::patchFile('spc_fix_xlswriter_win32.patch', $this->source_dir);

0 commit comments

Comments
 (0)