# why these code cause compile error?

- Thread: https://externals.io/message/41680
- Original archive: https://news-web.php.net/php.internals/41680
- Started by zhangsilly@gmail.com on 2008-11-05T09:07:31+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #41680 — zhangsilly@gmail.com — 2008-11-05T09:07:31+00:00

URL: https://externals.io/message/41680#41680

I 'am a new guy of  php internal, I tried to define a class in extension
just for a attempt.

PHP_MINIT_FUNCTION(zhangjianyu)
{
 /* If you have INI entries, uncomment these lines
 REGISTER_INI_ENTRIES();
 */
 zend_class_entry ce;
 INIT_CLASS_ENTRY(ce, WPS_CLASS_NAME, php_wps_method_functions);
 php_wps_sc_entry = zend_register_internal_class(&ce TSRMLS_CC);
 zend_declare_class_constant_double(php_wps_sc_entry, "VERSION",
sizeof("VERSION"), 1.32 TSRMLS_DC);
 zend_declare_class_constant_string(php_wps_sc_entry, "NAME",
sizeof("NAME"), "say say" TSRMLS_DC);
 return SUCCESS;
}

The Code above will cause compile errors like this: error C2059: syntax
error : 'type', just indicate the line
zend_declare_class_constant_double(php_wps_sc_entry, "VERSION",
sizeof("VERSION"), 1.32 TSRMLS_DC); is not correct.

Either I use  zend_declare_class_constant_double or
usezend_declare_property_null(php_wps_sc_entry, "name", strlen("name"),
 ZEND_ACC_PUBLIC TSRMLS_DC),both of them will cause the same error : error
C2059: syntax error : 'type'

---

## #41682 — johannes@php.net — 2008-11-05T12:49:44+00:00

URL: https://externals.io/message/41680#41682 · In reply to: #41680

> I 'am a new guy of  php internal, I tried to define a class in extension
> just for a attempt.
> 
> PHP_MINIT_FUNCTION(zhangjianyu)
> {
>  /* If you have INI entries, uncomment these lines
>  REGISTER_INI_ENTRIES();
>  */
>  zend_class_entry ce;
>  INIT_CLASS_ENTRY(ce, WPS_CLASS_NAME, php_wps_method_functions);
>  php_wps_sc_entry = zend_register_internal_class(&ce TSRMLS_CC);
>  zend_declare_class_constant_double(php_wps_sc_entry, "VERSION",
> sizeof("VERSION"), 1.32 TSRMLS_DC);
>  zend_declare_class_constant_string(php_wps_sc_entry, "NAME",
> sizeof("NAME"), "say say" TSRMLS_DC);

TSRMLS_DC = declaration with comma
you need
TSRMLS_CC = call with comma

Sara has a nice blog article about them (blog.libssh2.org or
something, ...)

johannes
