2016-07-03 4 views
0

enter image description here컴파일 오류 Chaiscript 비주얼 스튜디오 2015 커뮤니티

오류 :

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);"); 
} 

답변

2

당신은 당신의 시험에서 chaiscript::fun() 전화를 누락되었습니다.

chai.add(chaiscript::fun(&function), "function"); 

난 강력하게 당신이 examples page에서 제공하는 전체 예제로 시작하는 것이 좋습니다 : 당신이 표준 라이브러리를 찾을 수없는 이유를 궁금해 할 때

#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\"));"); 
} 

그렇지 않으면 당신은 신속하게 다른 오류로 실행하겠습니다.

관련 문제