I’m writing small php extension and have problem when building it.
The code:
PHP_RINIT_FUNCTION(pstat)
{
int argc = ZEND_NUM_ARGS();
return SUCCESS;
}
on make got an error:
.... /ext/pstat/pstat.c:122:31: error: 'ht' undeclared (first use in this function)
ZEND_NUM_ARGS() is a macros in Zend_API.h
#define ZEND_NUM_ARGS() (ht)
but what is ‘ht’? Any ideas?
Why are you using
ZEND_NUM_ARGS()here? This is the request initialisation function, and will not be receiving any user supplied arguments.Typically but not always,
htis used to denote a hash table.ZEND_NUM_ARGS()is usually used within a function defined with thePHP_FUNCTIONmacro, to get the number of arguments passed to an internal function from a PHP script.If you trace back from the
PHP_FUNCTIONmacro you’ll end up seeing the following standard set of arguments used in an internal function definition.As you can see, this definition includes
htas an int.The arguments for
PHP_RINIT_FUNCTIONdo not includeht.