Skip to content

Instantly share code, notes, and snippets.

@lefticus
Last active February 10, 2017 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lefticus/9456197 to your computer and use it in GitHub Desktop.
Save lefticus/9456197 to your computer and use it in GitHub Desktop.
#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\"));");
}
@totalgee
Copy link

Looks like this example need to be updated... The latest version of ChaiScript doesn't work with this usage. I think you'd need to replace ChaiScript with ChaiScript_Basic, in order for the first argument to still be the Std_Lib::library() (e.g. if you want to compile the standard library in a separate file). It seems you've changed the default ChaiScript constructor to create Std_Lib by default, rather than searching for an external library at runtime, as mentioned here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment