0

我试图在 C 中编写一个 PHP 扩展后phpize,我做./configure了并得到了这个错误

checking Whether extensionB is enabled... yes, shared
./configure: line 4171: syntax error near unexpected token `;'
./configure: line 4171: ;' 

我应该如何找到导致错误的行?有什么工具可以做到这一点?

文件夹结构

extensionB
         config.m4
         extensionB.c
         extensionB.h

配置.m4

PHP_ARG_ENABLE(extensionB, Whether extensionB is enabled, [--enable-extensionB enable extensionB support])

if $PHP_EXTENSIONB != "no" then
    PHP_NEW_EXTENSION(extensionB,extensionB.c,$ext_shared);
fi

扩展B.h

#ifndef PHP_EXTENSIONB_H
#define PHP_EXTENSIONB_H 1

#define PHP_EXTENSIONB_VERSION "1.0"
#define PHP_EXTENSIONB_EXTNAME "extensionB"

PHP_FUNCTION(extensionBFn1);

extern zend_module_entry extensionB_module_entry;
#define phpext_extensionB_ptr &extensionB_module_entry

#endif

扩展B.c

#include "php.h"
#include "extensionB.h"

static function_entry extensionBFns[] = 
{
 PHP_FE(extensionBFn1,NULL)
 {NULL,NULL,NULL}
};

zend_module_entry extensionB_module_entry = 
{
    STANDARD_MODULE_HEADER,
    PHP_EXTENSIONB_EXTNAME,
    extensionBFns,
    NULL,NULL,NULL,NULL,NULL,
    PHP_EXTENSIONB_VERSION,
    STANDARD_MODULE_PROPERTIES
};

#ifdef COMPILE_DL_EXTENSIONB
    ZEND_GET_MODULE(extensionB)
#endif

PHP_FUNCTION(extensionB)
{ 
  RETURN_STRING("Extension B returns a string from Fn 1",1);
}

编辑

通过我的代码,我意识到我的文件 config.m4 应该包含

if test "$PHP_EXTENSIONB" != "no";
then

现在它通过了 ./configure 阶段,但是否有任何工具可以显示该位置。像gdb?

4

1 回答 1

1

没有什么像 GDB 那样,但 configure.log 文件:搜索失败的测试,在它周围的行中,它告诉你准确执行了什么以及失败了什么。

于 2013-03-15T16:30:53.223 回答