Skip to content

php_hash_sha.h incompatible with C++ #15742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matyhtf opened this issue Sep 4, 2024 · 1 comment
Closed

php_hash_sha.h incompatible with C++ #15742

matyhtf opened this issue Sep 4, 2024 · 1 comment

Comments

@matyhtf
Copy link
Contributor

matyhtf commented Sep 4, 2024

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:

#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

Ubuntu 22.04.4 LTS

@cmb69
Copy link
Member

cmb69 commented Sep 4, 2024

See

#ifdef _MSC_VER
# define PHP_STATIC_RESTRICT
#else
# define PHP_STATIC_RESTRICT static restrict
#endif

That #ifdef _MSVC might need to be #if defined(_MSVC) || defined(__cplusplus).

@cmb69 cmb69 self-assigned this Sep 4, 2024
cmb69 added a commit to cmb69/php-src that referenced this issue Sep 4, 2024

Verified

This commit was signed with the committer’s verified signature. The key has expired.
cmb69 Christoph M. Becker
Not only MSVC doesn't support this construct, but apparently it is
generally not supported by C++ compilers.
@cmb69 cmb69 linked a pull request Sep 4, 2024 that will close this issue
@cmb69 cmb69 changed the title Build failed when including ext/hash/php_hash_sha.h in C++ extension php_hash_sha.h incompatible with C++ Sep 4, 2024
@cmb69 cmb69 closed this as completed in 5d1181f Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants