报错内容:
/Users/dre0m1/CTF/学习笔记/PHP源码/php-src/Zend/zend_language_parser.y:1317:5: error: implicit declaration of function 'yystpcpy' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
yystpcpy(yyres, "end of file");
^
/Users/dre0m1/CTF/学习笔记/PHP源码/php-src/Zend/zend_language_parser.y:1317:5: note: did you mean 'stpcpy'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/string.h:130:7: note: 'stpcpy' declared here
char *stpcpy(char *__dst, const char *__src);
^
/Users/dre0m1/CTF/学习笔记/PHP源码/php-src/Zend/zend_language_parser.y:1324:29: error: implicit declaration of function 'yystrlen' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
yystr_len = (unsigned int)yystrlen(yystr);
^
/Users/dre0m1/CTF/学习笔记/PHP源码/php-src/Zend/zend_language_parser.y:1324:29: note: did you mean 'strlen'?
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/string.h:82:9: note: 'strlen' declared here
size_t strlen(const char *__s);
^
/Users/dre0m1/CTF/学习笔记/PHP源码/php-src/Zend/zend_language_parser.y:1345:4: error: implicit declaration of function 'yystpcpy' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
yystpcpy(yyres, buffer);
^
/Users/dre0m1/CTF/学习笔记/PHP源码/php-src/Zend/zend_language_parser.y:1352:10: error: implicit declaration of function 'yystrlen' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
return yystrlen(yystr) - (*yystr == '"' ? 2 : 0);
^
/Users/dre0m1/CTF/学习笔记/PHP源码/php-src/Zend/zend_language_parser.y:1365:2: error: implicit declaration of function 'yystpcpy' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
yystpcpy(yyres, yystr);
^
5 errors generated.
make: *** [Zend/zend_language_parser.lo] Error 1
implicit declaration of function 'yystpcpy' is invalid in C99,网上查找资料可以发现这种报错类型与头文件或者前面的define相关,由报错中的提示可以看出应该是缺少了yystpcpy这个函数。
访问文件php-src/Zend/zend_language_parser.c,可以看到这样一段代码
向其中添加yystpcpy与yystrlen的定义,猜测他们的原本应该是stpcpy与strlen函数: 修改完后重新make,成功编译。