callback_for_c中的 Php::call()函数中的 function 是C++11的特性:
template <typename ...Params>
Value call(const char *name, Params&&... params)
{
// the name can be turned into a Php::Value object, which implements
// the operator () method to call it
Value function(name);
// invoke the operator ()
return function(std::forward<Params>(params)...);
}
这是我的程序文件b.cpp中函数 #ifdef __cplusplus extern "C" { #endif int32 callback_for_c(int32 lIdentifyCode,int16 nMsgType,void *pstMsg,int32 lMsgLen) { Php::Value relt; printf("callback c function sucess!\n"); // call a function from user space 调用用户的函数 Php::V
#ifdef __cplusplus
extern "C" {
#endif
int32 callback_for_c(int32 lIdentifyCode,int16 nMsgType,void *pstMsg,int32 lMsgLen)
{
Php::Value relt;
printf("callback c function sucess!\n");
// call a function from user space 调用用户的函数
Php::Value data = Php::call("some_function", "some_parameter");
printf("%s\n", "i arrival here!");
return int32_t(relt);
}
#ifdef __cplusplus
}
#endif
改成:
#ifdef __cplusplus
extern "C"
#endif
int32 callback_for_c(int32 lIdentifyCode,int16 nMsgType,void *pstMsg,int32 lMsgLen)
{
Php::Value relt;
printf("callback c function sucess!\n");
// call a function from user space 调用用户的函数
Php::Value data = Php::call("some_function", "some_parameter");
printf("%s\n", "i arrival here!");
return int32_t(relt);
}