在cpp头文件里面声明函数

#ifndef _HEAD_
#define _HEAD_

#ifdef __cplusplus
extern "C" 
{
#endif

#define export_api __attribute__ ((visibility("default")))

export_api int function1(int);
export_api void function2(gboolean, int);
...

#ifdef __cplusplus
};
#endif

#endif

 

然后在cpp的source 文件里面定义函数,在函数的实现里面调用CPP的类

#include <***.h>

NameSpace::Framework mFrameworkHandle;

extern "C" 
{

export_api int function1(int value)
{
    int ret = -1;
    ret = mFrameworkHandle.functionOne(value);//调用C++类中的方法
    return ret;
}

export_api void function2(gboolean flag,  int value)
{
    mFrameworkHandle.functionTwo(flag, value);//调用C++类中的方法  
}

};


参考

http://songpengfei.iteye.com/blog/1100239

相关文章:

  • 2022-12-23
  • 2021-06-05
  • 2021-06-21
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
猜你喜欢
  • 2021-09-27
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2021-06-21
  • 2022-12-23
相关资源
相似解决方案