2013-06-06 3 views
2

PHP 확장을 만들려고합니다. 여기 PHP 확장 오류 :

다음은 config.m4 파일 파일

PHP_ARG_ENABLE(hello, whether to enable Hello 
World support, 
[ --enable-hello Enable Hello World support]) 
if test "$PHP_HELLO" = "yes"; then 
    AC_DEFINE(HAVE_HELLO, 1, [Whether you have Hello World]) 
    PHP_NEW_EXTENSION(hello, hello.c, $ext_shared) 
fi 

인 php_hello.h 파일입니다. 여기

#ifndef PHP_HELLO_H 
#define PHP_HELLO_H 1 
#define PHP_HELLO_WORLD_VERSION "1.0" 
#define PHP_HELLO_WORLD_EXTNAME "hello" 

PHP_FUNCTION(hello_world); 

extern zend_module_entry hello_module_entry; 
#define phpext_hello_ptr &hello_module_entry 

#endif 

가에서는 hello.c 파일 내가 commands-

$ phpize 
$ ./configure --enable-hello 
$ make 

이하로 사용하여이 건물입니다

#ifdef HAVE_CONFIG_H 
#include "config.h" 
#endif 
#include "php.h" 
#include "php_hello.h" 

static function_entry hello_functions[] = { 
    PHP_FE(hello_world, NULL) 
    {NULL, NULL, NULL} 
}; 

zend_module_entry hello_module_entry = { 
#if ZEND_MODULE_API_NO >= 20010901 
    STANDARD_MODULE_HEADER, 
#endif 
    PHP_HELLO_WORLD_EXTNAME, 
    hello_functions, 
    NULL, 
    NULL, 
    NULL, 
    NULL, 
    NULL, 
#if ZEND_MODULE_API_NO >= 20010901 
    PHP_HELLO_WORLD_VERSION, 
#endif 
    STANDARD_MODULE_PROPERTIES 
}; 

#ifdef COMPILE_DL_HELLO 
ZEND_GET_MODULE(hello) 
#endif 

PHP_FUNCTION(hello_world) 
{ 
    RETURN_STRING("Hello World", 1); 
} 

입니다 점점이 내가

/usr/include/php/ext/hello/hello.c:8:5: warning: braces around scalar initializer [enabled by default] 
/usr/include/php/ext/hello/hello.c:8:5: warning: (near initialization for 'hello_functions[0]') [enabled by default] 
/usr/include/php/ext/hello/hello.c:8:5: warning: initialization makes integer from pointer without a cast [enabled by default] 
/usr/include/php/ext/hello/hello.c:8:5: warning: (near initialization for 'hello_functions[0]') [enabled by default] 
/usr/include/php/ext/hello/hello.c:8:5: error: initializer element is not computable at load time 
/usr/include/php/ext/hello/hello.c:8:5: error: (near initialization for 'hello_functions[0]') 
/usr/include/php/ext/hello/hello.c:8:5: warning: excess elements in scalar initializer [enabled by default] 
/usr/include/php/ext/hello/hello.c:8:5: warning: (near initialization for 'hello_functions[0]') [enabled by default] 
/usr/include/php/ext/hello/hello.c:8:5: warning: excess elements in scalar initializer [enabled by default] 
/usr/include/php/ext/hello/hello.c:8:5: warning: (near initialization for 'hello_functions[0]') [enabled by default] 
/usr/include/php/ext/hello/hello.c:8:5: warning: excess elements in scalar initializer [enabled by default] 
/usr/include/php/ext/hello/hello.c:8:5: warning: (near initialization for 'hello_functions[0]') [enabled by default] 
/usr/include/php/ext/hello/hello.c:8:5: warning: excess elements in scalar initializer [enabled by default] 
/usr/include/php/ext/hello/hello.c:8:5: warning: (near initialization for 'hello_functions[0]') [enabled by default] 
/usr/include/php/ext/hello/hello.c:9:5: warning: braces around scalar initializer [enabled by default] 
/usr/include/php/ext/hello/hello.c:9:5: warning: (near initialization for 'hello_functions[1]') [enabled by default] 
/usr/include/php/ext/hello/hello.c:9:5: warning: initialization makes integer from pointer without a cast [enabled by default] 
/usr/include/php/ext/hello/hello.c:9:5: warning: (near initialization for 'hello_functions[1]') [enabled by default] 
/usr/include/php/ext/hello/hello.c:9:5: warning: excess elements in scalar initializer [enabled by default] 
/usr/include/php/ext/hello/hello.c:9:5: warning: (near initialization for 'hello_functions[1]') [enabled by default] 
/usr/include/php/ext/hello/hello.c:9:5: warning: excess elements in scalar initializer [enabled by default] 
/usr/include/php/ext/hello/hello.c:9:5: warning: (near initialization for 'hello_functions[1]') [enabled by default] 
/usr/include/php/ext/hello/hello.c:17:5: warning: initialization from incompatible pointer type [enabled by default] 
/usr/include/php/ext/hello/hello.c:17:5: warning: (near initialization for 'hello_module_entry.functions') [enabled by default] 

를 오류 - 새로운이 문제를 어떻게 해결할 수 있습니까?

답변

7

나는 해결책을 얻었다. hello.c 파일에서, function_entry을 사용하고 있습니다. 5.4 이상에서는 작동하지 않습니다. function_entry 대신 zend_function_entry를 사용하십시오.

+1

감사합니다. 나는 이것을 읽을 때 포기했다. :) – Lykegenes