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);

发表评论

发表评论

*

沙发空缺中,还不快抢~