Mac 编译安装 PHP 时的 readdir_r 报错

使用 phpbrew 在编译安装PHP7.2.34时,发生了如下报错:

/Users/lufei/.phpbrew/build/php-7.2.34/main/reentrancy.c:139:23: error: too few arguments to function call, expected 3, have 2
        readdir_r(dirp, entry);
        ~~~~~~~~~            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/dirent.h:110:5: note: 'readdir_r' declared here
int readdir_r(DIR *, struct dirent *, struct dirent **) __DARWIN_INODE64(readdir_r);
    ^
1 error generated.
make: *** [main/reentrancy.lo] Error 1

这个报错的原因就是too few arguments to function call, expected 3, have 2,有三个参数这里只传了一个,所以在编译时就产生了错误

解决方法也很简单,修改对应的源码文件/Users/lufei/.phpbrew/build/php-7.2.34/main/reentrancy.c,第139行

readdir_r(dirp, entry);

改为第二个值的指针即可

readdir_r(dirp, entry, &entry);

1 条评论

发表评论

*

  • 你好 我用了你的GetFavicon项目,上传的v1版,但是每次打开网页都加载得很慢,和没有缓存的效果是一样的慢是怎么回事呢,js方法不能使用缓存吗,