Home >Backend Development >PHP Tutorial >编写PHP扩展遇到的 Z_OBJ_P warning问题

编写PHP扩展遇到的 Z_OBJ_P warning问题

WBOY
WBOYOriginal
2016-06-06 20:50:261342browse

想实现个简单的模板引擎扩展,最近在调试中.但是将扩展编译成so之后却发生了下面的状况:

运行make的时候出现以下warning:

<code class="lang-bash">/home/x64-debian-fxy/php5-5.4.4/ext/template_parser/template_parser.c: In function 'zif_template_parser_pause':
/home/x64-debian-fxy/php5-5.4.4/ext/template_parser/template_parser.c:114:21: warning: assignment makes pointer from integer without a cast [enabled by default]
</code>

相应代码段如下:

<code class="lang-cpp">//Fetch real object in order to fetch it's scope.
    if(Z_TYPE_P(object_container) == IS_OBJECT){
        //问题在下行.
        real_object = Z_OBJ_P(object_container);
    } else {
        real_object = NULL;
    }
</code>

起初我认为是宏的定义有问题,但是当我将Z_OBJ_P替换成应该使用的zend_object_get_address时,同样的warning会出现. 我在引入头文件时只是将php.h引入. 不知是否有同样经历的前辈解决过这样的问题,望指教!谢谢!

回复内容:

想实现个简单的模板引擎扩展,最近在调试中.但是将扩展编译成so之后却发生了下面的状况:

运行make的时候出现以下warning:

<code class="lang-bash">/home/x64-debian-fxy/php5-5.4.4/ext/template_parser/template_parser.c: In function 'zif_template_parser_pause':
/home/x64-debian-fxy/php5-5.4.4/ext/template_parser/template_parser.c:114:21: warning: assignment makes pointer from integer without a cast [enabled by default]
</code>

相应代码段如下:

<code class="lang-cpp">//Fetch real object in order to fetch it's scope.
    if(Z_TYPE_P(object_container) == IS_OBJECT){
        //问题在下行.
        real_object = Z_OBJ_P(object_container);
    } else {
        real_object = NULL;
    }
</code>

起初我认为是宏的定义有问题,但是当我将Z_OBJ_P替换成应该使用的zend_object_get_address时,同样的warning会出现. 我在引入头文件时只是将php.h引入. 不知是否有同样经历的前辈解决过这样的问题,望指教!谢谢!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn