php-ast icon indicating copy to clipboard operation
php-ast copied to clipboard

Fails to Compile with PHP 8 includes (changed prototype for "zend_prepare_string_for_scanning()")

Open TurtleWilly opened this issue 2 years ago • 1 comments

It looks like between PHP 7 and PHP 8 the return code of zend_prepare_string_for_scanning() was changed from "int" to "void", see includes/php/Zend/zend_language_scanner.h for the respective installation.

PHP 7: ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename); PHP 8: ZEND_API void zend_prepare_string_for_scanning(zval *str, zend_string *filename);

Naturally this breaks compilation with the following construct in the php-ast code base. It also triggers some warnings for the filename type.

if (zend_prepare_string_for_scanning(&code_zv, filename) == SUCCESS) {
		…
		}
/php-ast-1.0.4 $ make
/bin/sh /tmp/php-ast-1.0.4/libtool --mode=compile cc -I. -I/tmp/php-ast-1.0.4 -I/tmp/php-ast-1.0.4/include -I/tmp/php-ast-1.0.4/main -I/tmp/php-ast-1.0.4 -I/usr/local/php8/include/php -I/usr/local/php8/include/php/main -I/usr/local/php8/include/php/TSRM -I/usr/local/php8/include/php/Zend -I/usr/local/php8/include/php/ext -I/usr/local/php8/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2 -D_GNU_SOURCE    -DZEND_COMPILE_DL_EXT=1 -c /tmp/php-ast-1.0.4/ast.c -o ast.lo  -MMD -MF ast.dep -MT ast.lo
mkdir .libs
 cc -I. -I/tmp/php-ast-1.0.4 -I/tmp/php-ast-1.0.4/include -I/tmp/php-ast-1.0.4/main -I/tmp/php-ast-1.0.4 -I/usr/local/php8/include/php -I/usr/local/php8/include/php/main -I/usr/local/php8/include/php/TSRM -I/usr/local/php8/include/php/Zend -I/usr/local/php8/include/php/ext -I/usr/local/php8/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -D_GNU_SOURCE -DZEND_COMPILE_DL_EXT=1 -c /tmp/php-ast-1.0.4/ast.c -MMD -MF ast.dep -MT ast.lo  -fno-common -DPIC -o .libs/ast.o
/tmp/php-ast-1.0.4/ast.c:309:49: warning: incompatible pointer types passing 'char *' to parameter of type 'zend_string *' (aka 'struct _zend_string *') [-Wincompatible-pointer-types]
        if (zend_prepare_string_for_scanning(&code_zv, filename) == SUCCESS) {
                                                       ^~~~~~~~
/usr/local/php8/include/php/Zend/zend_language_scanner.h:78:72: note: passing argument to parameter 'filename' here
ZEND_API void zend_prepare_string_for_scanning(zval *str, zend_string *filename);
                                                                       ^
/tmp/php-ast-1.0.4/ast.c:309:59: error: invalid operands to binary expression ('void' and 'int')
        if (zend_prepare_string_for_scanning(&code_zv, filename) == SUCCESS) {
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~
1 warning and 1 error generated.
make: *** [ast.lo] Error 1

TurtleWilly avatar Jun 18 '23 19:06 TurtleWilly

Or rather… how about a new release? 😱 I guess 1.0.4 is a bit outdated.

TurtleWilly avatar Jun 18 '23 19:06 TurtleWilly

I guess this was building from github releases rather than tags. There is a "release" for v1.1.1 nowadays (https://github.com/nikic/php-ast/releases/tag/v1.1.1).

nikic avatar Aug 10 '24 16:08 nikic