Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/139.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用C++;工作 我有一个现有的C++库,其中有一个类,我想与PHP接口。我在这里尝试了一个简单的例子:在运行./configure时遇到语法错误_Php_C++_Class_Php Extension - Fatal编程技术网

无法使用C++;工作 我有一个现有的C++库,其中有一个类,我想与PHP接口。我在这里尝试了一个简单的例子:在运行./configure时遇到语法错误

无法使用C++;工作 我有一个现有的C++库,其中有一个类,我想与PHP接口。我在这里尝试了一个简单的例子:在运行./configure时遇到语法错误,php,c++,class,php-extension,Php,C++,Class,Php Extension,我的代码如下所示: [config.m4] PHP_ARG_ENABLE(sigx, [Whether to enable the "SIGX" extension], [ --enable-sigx Enable "SIGX" extension support]) if test "$PHP_SIGX" != "no"; then PHP_REQUIRE_CXX(); PHP_SUBST(SIGX_SHARED_LIBADD) PHP_ADD

我的代码如下所示:

[config.m4]
PHP_ARG_ENABLE(sigx,
    [Whether to enable the "SIGX" extension],
    [ --enable-sigx     Enable "SIGX" extension support])

if test "$PHP_SIGX" != "no"; then
    PHP_REQUIRE_CXX();
    PHP_SUBST(SIGX_SHARED_LIBADD)
    PHP_ADD_LIBRARY(stdc++, 1, SIGX_SHARED_LIBADD)
    PHP_NEW_EXTENSION(sigx, sigx.cc, $ext_shared)
fi

[sigx.h]
#ifndef PHP_SIGX_H
#define PHP_SIGX_H

#define PHP_SIGX_EXTNAME  "sigx"
#define PHP_SIGX_EXTVER   "0.1"

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

extern "C" {
#include "php.h"
}

extern zend_module_entry sigx_module_entry;
#define phpext_sigx_ptr &sigx_module_entry;

#endif /* PHP_SIGX_H */

[sigx.cc]
#include "php_sigx.h"

PHP_MINIT_FUNCTION(sigx)
{
    return SUCCESS;
}

zend_module_entry sigx_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
    STANDARD_MODULE_HEADER,
#endif
    PHP_SIGX_EXTNAME,
    NULL,                       // Functions
    PHP_MINIT(sigx),
    NULL,                       // MSHUTDOWN
    NULL,                       // RINIT
    NULL,                       // RSHUTDOWN
    NULL,                       // MINFO
#if ZEND_MODULE_API_NO >= 200010901
    PHP_SIGX_EXTVER,
#endif
    STANDARD_MODULE_PROPERTIES
};

#ifdef COMPILE_DL_SIGX
    extern "C" {
ZEND_GET_MODULE(sigx)
}
#endif

$ phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626

$ ./configure
...
...
checking for re2c version... 0.13.5 (ok)
checking for gawk... gawk
checking Whether to enable the "SIGX" extension... yes, shared
./configure: line 4785: syntax error near unexpected token `;'
./configure: line 4785: `;'


ac_compiler_gnu=$ac_cv_c_compiler_gnu

    php_cxx_done=yes
  fi
;    <----  This is line 4785

  PHP_VAR_SUBST="$PHP_VAR_SUBST SIGX_SHARED_LIBADD"
[config.m4]
PHP_ARG_ENABLE(sigx,
[是否启用“SIGX”扩展],
[--启用sigx启用“sigx”扩展支持])
如果测试“$PHP_SIGX”!=“不”;然后
PHP_REQUIRE_CXX();
PHP_SUBST(SIGX_SHARED_LIBADD)
PHP_添加_库(stdc++,1,SIGX_共享_LIBADD)
PHP_新_扩展(sigx,sigx.cc,$ext_共享)
fi
[sigx.h]
#ifndef PHP_SIGX_H
#定义PHP_SIGX_H
#定义PHP_SIGX_EXTNAME“SIGX”
#定义PHP_SIGX_EXTVER“0.1”
#如果定义有配置
#包括“config.h”
#恩迪夫
外部“C”{
#包括“php.h”
}
外部zend_模块输入sigx_模块输入;
#定义phpext_sigx_ptr&sigx_模块_条目;
#endif/*PHP_SIGX_H*/
[sigx.cc]
#包括“php_sigx.h”
PHP_MINIT_函数(sigx)
{
回归成功;
}
zend_模块输入sigx_模块输入={
#如果ZEND_模块API_编号>=20010901
标准模块标题,
#恩迪夫
PHP_SIGX_EXTNAME,
NULL,//函数
PHP_MINIT(sigx),
NULL,//mshutton
NULL,//RINIT
NULL,//rshutton
NULL,//MINFO
#如果ZEND_模块API_编号>=20000901
PHP_SIGX_EXTVER,
#恩迪夫
标准模块属性
};
#ifdef编译_DL_SIGX
外部“C”{
ZEND_GET_模块(sigx)
}
#恩迪夫
$phpize
配置用于:
PHP Api版本:20090626
Zend模块Api编号:20090626
Zend扩展Api编号:220090626
美元/配置
...
...
正在检查re2c版本。。。0.13.5(正常)
正在检查是否有呆滞。。。目瞪口呆
正在检查是否启用“SIGX”扩展。。。是的,共享
./configure:第4785行:意外标记“;”附近的语法错误
/配置:第4785行:`;'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
php\u cxx\u done=是
fi

; 好的,快速更新。只需删除带有分号的那一行,错误就会消失。现在,我有不同的问题,但问题消失了。我一开始就不想把它放在那里!天哪,我是个白痴。我在宏中有一个额外的分号!PHP_REQUIRE_CXX();啊。。。。