#include <iostream>
#include "include/dyncall.h"
class test
{
public:
test(int x):value(x){}
void print(){ std::cout << value << std::endl; }
private:
int value;
};
char* show(int x, double y, bool b, char c, const char* p,
test* t, test& h)
{
std::cout << "helloworld from show..(" << x << ", " << y
<< ", " << c << ", " << p << ")" << std::endl;
std::cout << std::boolalpha << b << std::endl;
t->print();
h.print();
return "testforcharpointer";
}
int main()
{
DCCallVM* vm = dcNewCallVM(4096);
test t(119);
test h(112);
//参数传递从左往右
dcArgInt(vm, 10);
dcArgDouble(vm, 12.00);
dcArgBool(vm, false);
dcArgChar(vm, 'A');
dcArgPointer(vm, "kitty");
dcArgPointer(vm, &t);
dcArgPointer(vm, &h);
void* p = dcCallPointer(vm, (void*)&show);
std::cout << (char*)p << std::endl;
system("pause");
return 0;
}
使用dyncall动态调用函数
最新推荐文章于 2023-11-11 16:56:01 发布