asIScriptModule *mod = engine->GetModule("ScriptModule");
asIScriptFunction *func = mod->GetFunctionByDecl("void main()");
if( func == 0 )
{
// The function couldn't be found. Instruct the script writer
// to include the expected function in the script.
printf("The script must have the function 'void main()'. Please add it and try again.\n");
return;
}
// Create our context, prepare it, and then execute
asIScriptContext *ctx = engine->CreateContext();
ctx->Prepare(func);
int r = ctx->Execute();
if( r != asEXECUTION_FINISHED )
{
// The execution didn't complete as expected. Determine what happened.
if( r == asEXECUTION_EXCEPTION )
{
// An exception occurred, let the script writer know what happened so it can be corrected.
printf("An exception '%s' occurred. Please correct the code and try again.\n", ctx->GetExceptionString());
}
}
When my program reaches ctx->Prepare(); the program crashes. Does anybody know how to fix it?
If you need, I can give you the whole code.