参考 http://www.phpvim.net/web/php/build-php5-4-and-xdebug-on-win32.html
1. error C2466: cannot allocate an array of constant size 0
用C/C++写PHP的扩展模块,如果VS2005编译,可能会出现下面的错误:
<VS2005安装目录>\VC\include\sys/stat.inl(44) : error C2466: 不能分配常量大小为 0 的数组
,出现这种情况时,只需在 <VS2005安装目录>\vc\include\malloc.h 文件中找到:
#define _STATIC_ASSERT(expr) typedef char __static_assert_t[ (expr) ]
并改成:
#ifdef PHP_WIN32
#define _STATIC_ASSERT(expr) typedef char __static_assert_t[ (expr)?(expr):1 ]
#else
#define _STATIC_ASSERT(expr) typedef char __static_assert_t[ (expr) ]
#endif
就可以了。
单独编译 pdo:
打开 VS2005 命令行工具
1)执行命令cscript /nologo configure.js --enable-pdo
php error C2491: 'strnlen' : definition of dllimport function
https://bugs.php.net/bug.php?id=47787
Description:
------------
Building 5.2.9 with VC++ 2005 results in the error:
main\spprintf.c(184) : error C2491: 'strnlen' : definition of dllimport function not allowed
This appears to be due to the change here: http://cvs.php.net/viewvc.cgi/php-src/main/spprintf.c?r1=1.25.2.2.2.14&r2=1.25.2.2.2.15
The issue is resolved by adding:
#define HAVE_STRNLEN 1
to win32/build/config.w32.h.in
2)ext\dom\php_dom.h(33) : fatal error C1083: Cannot open include file: 'libxml/parser.h': No such file or directory
修改 config 命令:cscript /nologo configure.js --enable-pdo --without-libxml
3)ext\calendar\jewish.c(324) : error C2001: newline in constant
关于 calendar.c 和 jewish.c 的编码问题:
这两个文件使用的是 ANSI 编码,包含有一些西文的特殊字符,GBK 字符集中不存在。
可用 editplus 打开,编码选择:West European (Windows),另存为 UTF-8。