我目前正在使用 ChaiScript 6.0.0 版和 Visual Studio 2017。
在我的 C++ 中,我正在on_init()
从脚本文件中检索对函数的引用并执行它。ChaiScript 对象是使用默认/空构造函数构造的。该函数如下所示:
def on_init() {
use("scripts/test.chai");
}
“scripts/test.chai”的内容如下所示:
class A {
def A() {
print("Created an instance of A!");
}
}
我的文件结构如下所示:
bin
\
| my_executable.exe
| scripts
\
| main_menu.chai
| test.chai
执行on_init()
上面显示的函数时,控制台会打印以下消息:
Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use" Error: "Can not find object: use"
在构造 ChaiScript 对象时提供“使用路径”会导致相同的情况。
我也试过use("test.chai")
了use("scripts/test.chai")
,两者都会产生相同的消息。
我没有提供chaiscript::Options
关于 ChaiScript 对象构造的任何枚举,因此它应该使用默认值(它似乎包含External_Scripts
和Load_Modules
)。
我正在编译禁用线程安全的 ChaiScript。
我在此脚本主体中运行任何其他内置函数都没有任何问题,包括我正在以与此相同的方式检索(到 C++ 中)的其他函数。
如果需要更多信息,请告诉我。
我是否错误地使用了“使用”功能?