在配置阶段确定错误位置的工具/技巧 - PHP扩展编码

时间:2013-03-15 14:36:32

标签: c debugging syntax-error php-extension

我试图在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

的config.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

extensionB.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

extensionB.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?

1 个答案:

答案 0 :(得分:1)

没有像GDB这样的东西,但是configure.log文件:搜索失败的测试,并在其周围的行中,它告诉你什么是完全执行的和失败的。