
错误:
Error C2664 'void chaiscript::detail::Dispatch_Engine::add(const chaiscript::Type_Info &,const std::string &)': cannot convert argument 1 from 'double (__cdecl *const )(int,double)' to 'const chaiscript::Proxy_Function &' Chaiscript c:\users\kung\documents\visual studio 2015\projects\chaiscript\chaiscript\language\chaiscript_engine.hpp 764 示例代码:
//main.cpp
#include "chaiscript/chaiscript.hpp"
double function(int i, double j)
{
return i * j;
}
int main()
{
chaiscript::ChaiScript chai;
chai.add(&function, "function");
double d = chai.eval<double>("function(3, 4.75);");
} 发布于 2016-07-05 14:16:28
在您的测试中,您错过了chaiscript::fun()调用。
chai.add(chaiscript::fun(&function), "function");我强烈建议您从示例页上提供的完整示例开始
#include <chaiscript/chaiscript.hpp>
#include <chaiscript/chaiscript_stdlib.hpp>
std::string helloWorld(const std::string &t_name)
{
return "Hello " + t_name + "!";
}
int main()
{
chaiscript::ChaiScript chai(chaiscript::Std_Lib::library());
chai.add(chaiscript::fun(&helloWorld), "helloWorld");
chai.eval("puts(helloWorld(\"Bob\"));");
}否则,当您想知道为什么它找不到标准库时,您很快就会遇到另一个错误。
https://stackoverflow.com/questions/38171794
复制相似问题