Search code examples
compiler-errorsphp-7php-extension

Porting php5 extension to php7 and MAKE_STD_ZVAL missing


I'm trying to compile a php5 extension for php7, but run against some problems with MAKE_STD_ZVAL, which no longer seems to exist in php7.

I'm trying to compile: php-sweph Which makes some c functions available for some astronomical calculations. I'm no c experts, and am only interested in making this module working for php7. So what's the MAKE_STD_ZVAL all about, and wondering about how or what do i need to change so the function below works without the MAKE_STD_ZVAL?

PHP_FUNCTION(swe_houses)
{
   char *arg = NULL;
   int hsys_len, rc;
   char *hsys = NULL;
   double tjd_ut, geolat, geolon;
   double cusps[37], ascmc[10]; 
   int i, houses;
   zval *cusps_arr, *ascmc_arr;

   if(ZEND_NUM_ARGS() != 4) WRONG_PARAM_COUNT;

   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddds",
        &tjd_ut, &geolat, &geolon, &hsys, &hsys_len) == FAILURE) {
        return;
   }

   if (hsys_len < 1)
        return;

   rc = swe_houses(tjd_ut, geolat, geolon, hsys[0], cusps, ascmc);

   /* create 2 index array, and 1 assoc array */
   array_init(return_value);

   MAKE_STD_ZVAL(cusps_arr);
   array_init(cusps_arr);

   if (hsys[0] == 'G')
       houses = 37;
   else
       houses = 13;

   for(i = 0; i < houses; i++)
       add_index_double(cusps_arr, i, cusps[i]);

       MAKE_STD_ZVAL(ascmc_arr);

       array_init(ascmc_arr);

   for(i = 0; i < 10; i++)

   add_index_double(ascmc_arr, i, ascmc[i]);

   add_assoc_zval(return_value, "cusps", cusps_arr);
   add_assoc_zval(return_value, "ascmc", ascmc_arr);
   add_assoc_long(return_value, "rc", rc);
}

Solution

  • this link mentioned the details of macros that are changed or removed from php 7.