[php-src] Issue #15742: Build failed when including `ext/hash/php_hash_sha.h` in C++ extension

From: Date: Wed, 04 Sep 2024 08:26:00 +0000
Subject: [php-src] Issue #15742: Build failed when including `ext/hash/php_hash_sha.h` in C++ extension
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-247693@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/15742 Author: matyhtf ### Description ## Error: ``` g++ -I. -I/home/htf/workspace/swoole -I/opt/php-8.4-zts/include/php -I/opt/php-8.4-zts/include/php/main -I/opt/php-8.4-zts/include/php/TSRM -I/opt/php-8.4-zts/include/php/Zend -I/opt/php-8.4-zts/include/php/ext -I/opt/php-8.4-zts/include/php/ext/date/lib -I/usr/include/x86_64-linux-gnu -I/usr/local/include -I/thirdparty -I/home/htf/workspace/swoole -I/home/htf/workspace/swoole/include -I/home/htf/workspace/swoole/ext-src -I/home/htf/workspace/swoole/thirdparty -I/home/htf/workspace/swoole/thirdparty/hiredis -DHAVE_CONFIG_H -g -O0 -Wall -Wno-unused-function -Wno-deprecated -Wno-deprecated-declarations -std=c++11 -I/usr/include/postgresql -I/opt/php-8.4-zts/include/php/ext -I/usr/include -DPDO_ODBC_TYPE=\"unixODBC\" -DENABLE_PHP_SWOOLE -DZEND_COMPILE_DL_EXT=1 -c /home/htf/workspace/swoole/ext-src/swoole_mysql_coro.cc -MMD -MF ext-src/swoole_mysql_coro.dep -MT ext-src/swoole_mysql_coro.lo -fPIC -DPIC -o ext-src/.libs/swoole_mysql_coro.o In file included from /home/htf/workspace/swoole/ext-src/swoole_mysql_coro.cc:31: /opt/php-8.4-zts/include/php/ext/hash/php_hash_sha.h:51:30: error: expected primary-expression before ‘static’ 51 | # define PHP_STATIC_RESTRICT static restrict | ^~~~~~ /opt/php-8.4-zts/include/php/ext/hash/php_hash_sha.h:55:43: note: in expansion of macro ‘PHP_STATIC_RESTRICT’ 55 | void SHA256_Transform_sse2(uint32_t state[PHP_STATIC_RESTRICT 8], const uint8_t block[PHP_STATIC_RESTRICT 64], uint32_t W[PHP_STATIC_RESTRICT 64], uint32_t S[PHP_STATIC_RESTRICT 8]); | ^~~~~~~~~~~~~~~~~~~ /opt/php-8.4-zts/include/php/ext/hash/php_hash_sha.h:55:43: error: expected ‘]’ before ‘static’ 55 | void SHA256_Transform_sse2(uint32_t state[PHP_STATIC_RESTRICT 8], const uint8_t block[PHP_STATIC_RESTRICT 64], uint32_t W[PHP_STATIC_RESTRICT 64], uint32_t S[PHP_STATIC_RESTRICT 8]); | ^ | ] /opt/php-8.4-zts/include/php/ext/hash/php_hash_sha.h:55:43: error: expected ‘)’ before ‘static’ 55 | void SHA256_Transform_sse2(uint32_t state[PHP_STATIC_RESTRICT 8], const uint8_t block[PHP_STATIC_RESTRICT 64], uint32_t W[PHP_STATIC_RESTRICT 64], uint32_t S[PHP_STATIC_RESTRICT 8]); | ~ ^ | ) /opt/php-8.4-zts/include/php/ext/hash/php_hash_sha.h:51:30: error: expected initializer before ‘static’ 51 | # define PHP_STATIC_RESTRICT static restrict | ^~~~~~ /opt/php-8.4-zts/include/php/ext/hash/php_hash_sha.h:55:43: note: in expansion of macro ‘PHP_STATIC_RESTRICT’ 55 | void SHA256_Transform_sse2(uint32_t state[PHP_STATIC_RESTRICT 8], const uint8_t block[PHP_STATIC_RESTRICT 64], uint32_t W[PHP_STATIC_RESTRICT 64], uint32_t S[PHP_STATIC_RESTRICT 8]); | ^~~~~~~~~~~~~~~~~~~ /opt/php-8.4-zts/include/php/ext/hash/php_hash_sha.h:51:30: error: expected primary-expression before ‘static’ 51 | # define PHP_STATIC_RESTRICT static restrict | ^~~~~~ /opt/php-8.4-zts/include/php/ext/hash/php_hash_sha.h:67:44: note: in expansion of macro ‘PHP_STATIC_RESTRICT’ 67 | void SHA256_Transform_shani(uint32_t state[PHP_STATIC_RESTRICT 8], const uint8_t block[PHP_STATIC_RESTRICT 64]); | ^~~~~~~~~~~~~~~~~~~ In file included from /home/htf/workspace/swoole/ext-src/swoole_mysql_coro.cc:31: /opt/php-8.4-zts/include/php/ext/hash/php_hash_sha.h:67:44: error: expected ‘]’ before ‘static’ 67 | void SHA256_Transform_shani(uint32_t state[PHP_STATIC_RESTRICT 8], const uint8_t block[PHP_STATIC_RESTRICT 64]); | ^ | ] /opt/php-8.4-zts/include/php/ext/hash/php_hash_sha.h:67:44: error: expected ‘)’ before ‘static’ 67 | void SHA256_Transform_shani(uint32_t state[PHP_STATIC_RESTRICT 8], const uint8_t block[PHP_STATIC_RESTRICT 64]); | ~ ^ | ) In file included from /home/htf/workspace/swoole/ext-src/swoole_mysql_coro.cc:31: /opt/php-8.4-zts/include/php/ext/hash/php_hash_sha.h:51:30: error: expected initializer before ‘static’ 51 | # define PHP_STATIC_RESTRICT static restrict | ^~~~~~ /opt/php-8.4-zts/include/php/ext/hash/php_hash_sha.h:67:44: note: in expansion of macro ‘PHP_STATIC_RESTRICT’ 67 | void SHA256_Transform_shani(uint32_t state[PHP_STATIC_RESTRICT 8], const uint8_t block[PHP_STATIC_RESTRICT 64]); | ^~~~~~~~~~~~~~~~~~~ make: *** [Makefile:306:ext-src/swoole_mysql_coro.lo] Error 1 ``` ## Code: ```cpp #include "php_swoole_cxx.h" #include "php_swoole_mysql_proto.h" #include "swoole_string.h" // see mysqlnd 'L64' macro redefined #undef L64 SW_EXTERN_C_BEGIN #include "ext/hash/php_hash.h" #include "ext/hash/php_hash_sha.h" #include "ext/standard/php_math.h" #ifdef SW_USE_MYSQLND #include "ext/mysqlnd/mysqlnd.h" #include "ext/mysqlnd/mysqlnd_charset.h" #endif SW_EXTERN_C_END ``` ### PHP Version PHP 8.4 ### Operating System _No response_

« previous php.bugs (#247693) next »