Topic: php 8 compiler define error
Hi Remi,
I'm running into an issue with PHP 8 and v8js. I'm not sure if it is related to your packages, but I was hoping you could help narrow it down:
I'm running CentOS 8 and PHP 8, and trying to compile v8js which is not officially ready for PHP 8 (https://github.com/phpv8/v8js/issues/458), but when I was trying the PR posted in that issue, I'm getting an odd compile error:
In file included from /usr/local/src/v8js-php8/php_v8js_macros.h:35,
from /usr/local/src/v8js-php8/v8js_v8.cc:19:
/opt/remi/php80/root/usr/include/php/main/php_config.h:26:18: error: expected identifier before string constant
#define COMPILER "gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5)"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/remi/php80/root/usr/include/php/main/php_config.h:26:18: note: in definition of macro ‘COMPILER’
#define COMPILER "gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5)"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/remi/php80/root/usr/include/php/main/php_config.h:26:18: error: expected ‘}’ before string constant
#define COMPILER "gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5)"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/remi/php80/root/usr/include/php/main/php_config.h:26:18: note: in definition of macro ‘COMPILER’
#define COMPILER "gcc (GCC) 8.3.1 20191121 (Red Hat 8.3.1-5)"
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I don't know C/C++ well-enough, but if I remove the "#define COMPILER" line in php_config.h, it compiles cleanly. If I change COMPILER to be something else like COMPILER123, then it compiles cleanly too. I don't see COMPILER defined in php_config.h in PHP 7.4.
From looking at other included files, v8/include/v8.h defines an enum called StateTag with a value of COMPILER - see https://github.com/v8/v8/blob/master/include/v8.h#L2359. If I comment out that line, then it compiles cleanly too.
I tried compiling PHP 8 manually, and v8js compiled cleanly since my php_config.h had "/* #undef COMPILER */" for that line.
Could the 2 constants be conflicting in some form? Do you have any recommendations on how to best resolve it?
Thank you for your help.
Ryan