您好,欢迎访问一九零五行业门户网

使用VC++开发PHP扩展注意事项_PHP教程

一、默认情况下,c++是使用.cpp作为扩展名的,而php是用c写的,因此必须使用c++提供的c连接交换指定符号extern c来解决这个问题,以下两部分语句必须被包含:
extern c {
#include php.h
#include php_ini.h
#include ext/standard/info.h
... // 其他c头文件
}

extern c {
#ifdef compile_dl_myext
zend_get_module(myext)
#endif
}
二、stl模版定义是不能被包含在c连接交换指定符的,而php需用到math.h这个头文件,因此编译的时候会产生math.h(514) error c2894: templates cannot be declared to have 'c' linkage的错误信息,要解决这个问题,需在你的cpp文件头部也就是extern c连接符之前加入以下代码:
#ifdef win32
#include
#endif
三、同c中一样,必须先在头文件如:php_myext.h)中申明所有函数原型,如果没有使用头文件,那么必须在cpp文件如:ext.cpp)的zend function结构之间申明所有函数原型,也就是在如下代码之前:
function_entry myext_functions[] = {
php_fe(confirm_myext_compiled, null) /* for testing, remove later. */
{null, null, null}
};
http://www.bkjia.com/phpjc/589781.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/589781.htmltecharticle一、默认情况下,c++是使用.cpp作为扩展名的,而php是用c写的,因此必须使用c++提供的c连接交换指定符号extern c来解决这个问题,以下两部...
其它类似信息

推荐信息