Skip to content

Commit

Permalink
Fix swoole_compile_string() build error (#4466)
Browse files Browse the repository at this point in the history
  • Loading branch information
twose authored Nov 4, 2021
1 parent e1c4947 commit b618e86
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions ext-src/php_swoole_cxx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,23 @@ typedef zval zend_source_string_t;
typedef zend_string zend_source_string_t;
#endif

static zend_op_array *swoole_compile_string(zend_source_string_t *source_string, ZEND_STR_CONST char *filename);
#if PHP_VERSION_ID < 80200
#define ZEND_COMPILE_POSITION_DC
#define ZEND_COMPILE_POSITION_RELAY_C
#else
#define ZEND_COMPILE_POSITION_DC , zend_compile_position position
#define ZEND_COMPILE_POSITION_RELAY_C , position
#endif

// for compatibly with dis_eval
static zend_op_array *(*old_compile_string)(zend_source_string_t *source_string, ZEND_STR_CONST char *filename);
static zend_op_array *(*old_compile_string)(zend_source_string_t *source_string, ZEND_STR_CONST char *filename ZEND_COMPILE_POSITION_DC);

static zend_op_array *swoole_compile_string(zend_source_string_t *source_string, ZEND_STR_CONST char *filename) {
static zend_op_array *swoole_compile_string(zend_source_string_t *source_string, ZEND_STR_CONST char *filename ZEND_COMPILE_POSITION_DC) {
if (UNEXPECTED(EG(exception))) {
zend_exception_error(EG(exception), E_ERROR);
return nullptr;
}
zend_op_array *opa = old_compile_string(source_string, filename);
zend_op_array *opa = old_compile_string(source_string, filename ZEND_COMPILE_POSITION_RELAY_C);
opa->type = ZEND_USER_FUNCTION;
return opa;
}
Expand Down

0 comments on commit b618e86

Please sign in to comment.