   Can t get it to work
 1 #include <iostream> 2 #include <angelscript.h> 3 using namespace std; 4 5 void Print(float value) 6 { 7 cout<<value<<endl; 8 } 910 void MessageCallback(const asSMessageInfo *msg, void *param)11 {12 const char *type = "ERR ";13   if( msg->type == asMSGTYPE_WARNING )14type = "WARN";15  else if( msg->type == asMSGTYPE_INFORMATION )16    type = "INFO";17 cout<<  msg->section<<msg->row<< msg->col<< type<< msg->message<<endl;18 }1920 const char *szScript ="float globalval=0;void dosomething(){Print(globalvar);}";21 int main(int argc,char*argv[])22 {23    int i;24    asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);2526    i = engine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL);27    assert(i>=0);282930    i = engine->RegisterGlobalFunction("void Print(float)", asFUNCTION(Print), asCALL_CDECL);31    assert(i>=0);32    engine->AddScriptSection("test","start",szScript,56);33    engine->Build("test");3435    // Do some preparation before execution36    asIScriptContext *context = engine->CreateContext();37    int functionID = engine->GetFunctionIDByDecl("test", "void dosomething()");3839    // Execute the script function40    context->Prepare(functionID);41    context->Execute();4243    // Release the context when finished with it44    context->Release();45    return 0;46 }It doesn t let me set a callback in the first place and the rest doesn t work eitherbasiror@linux:~> g++ -o template template.cpp -langelscriptbasiror@linux:~> ./templatetemplate: template.cpp:27: int main(int, char**): Assertion `i>=0' failed.Abortedbasiror@linux:~>Any idea what I am doing wrong here?I am under Suse 10.0 x86_64 with an amd64Compiling the lib with AS_MAX_PORTABILITY didn t work either[Edited by - Basiror on July 21, 2006 3:49:56 AM]
  Hmm, it should work. What version of AngelScript are you using? Have you retrieved the latest version from SVN?All the tests, except saving and loading bytecode, in the test_feature project works for 64bit Linux with amd64. I've tested this on SourceForge.net's compile farm.Perhaps you could debug your test sample to check the value of i? Or even go into the SetMessageCallback to see where it decides to return a negative value?;  I just fixed a bug in as_bytecode.cpp and checked in the new code in revision 49. You should be able to compile and use AngelScript on amd64 and Linux now.There is a bug in the 64bit version of AngelScript though, I've not been able to locate the bug though as it is not consistent. Depending on the order of the individual tests in test_features some of the tests fail, but when I move the test that failed to the top (for easier debugging) it doesn't fail anymore. Even the saving and loading of bytecode works when executed as the first test.I think it is memory related, in that in some situations the generated bytecode doesn't quite clean up the script stack as it should. I'll try to locate the bug by adding asserts that validates the stack frame pointer.If you can find a situation that faithfully reproduce the problem I would be very grateful.Regards,Andreas   ;  Hi, thanx for taking the time to fix these bugs, unfortunately I found another oncegcc -g -Wall -o obj/as_callfunc.o -c ../../source/as_callfunc.cpp../../source/as_callfunc.cpp: In function ‘int DetectCallingConvention(bool, const asUPtr&, int, asSSystemFunctionInterface*)’:../../source/as_callfunc.cpp:69: error: cast from ‘void (*)()’ to ‘asDWORD’ loses precisionmake: *** [obj/as_callfunc.o] Error 1pointers have a size of 8 bytesand int have a size of 4 bytesjust tested this on my machineP.S.: Did you use a parser generator to write the language parser to did you use hand parsing?   ;  Ah, I fixed this yesterday in revision 50. Let me know if there are any other problems.The parser is hand made. It's in as_parser.cpp if you're interested in looking at the code.   ;  I can run scripts now, but there s one further problem that I could not solveI want to register a cfunction, see snippets underneath 9 void Prints(std::string &in)10 {11    cout << in<<endl;12 }41    i = engine->RegisterGlobalFunction("void Prints(string &in)",asFUNCTION(Prints),asCALL_GENERIC);The script looks as follows:float globalval=0; string msg ="hallo";void dosomething(){Prints(msg);Print(globalval);}The message callback prints thisSystem function 1 13 ERR  Identifier 'string' is not a data type 0 0 ERR  Invalid configurationAny idea what I am doing wrong here?Btw is 2.7.0 == rev 50?;  AngelScript doesn't have a built-in string type. You must first register one. You can do this by calling the RegisterScriptString() function of the add-on script string (/add_on/scriptstring/scriptstring.cpp), or you can register your own string type.Also, you need to use the correct calling convention when registering your functions. Your Prints() functions should use the calling convention asCALL_CDECL, or you need to rewrite the function to use the generic interface, i.e:void Prints(asIScriptGeneric *gen){    std::string *in = (std::string*)gen->GetArgAddress(0);    cout << *in <<endl;}Since you're using amd64, then the generic calling convention is the only available, until I can add support for the native calling conventions.Regards,Andreas   ;  Ok thx for the help   