I am making a mobile game engine that runs on TinyXML and Angelscript. I'm using MSVC 2010 Professional. I used the Marmalade Angelscript project found in this thread and it seems to be working. So far, I've made it so I can define hierarchical game objects and their properties in XML, and optionally reference Angelscript scripts that specialize the functionality even further. Angelscript looks very promising, and while there've been a few hiccups I couldn't find reference to in the documentation, the library seems to be designed sensibly enough that with enough persistence I can usually figure out what's wrong.
Now, however, I'm completely stuck. I suspect the issue may lie with Marmalade as much as Angelscript. The engine runs flawlessly when I compile to x86 and run it in the Marmalade simulator. However, when I want to compile to ARM so I can run on an iOS device, something bad happens and it crashes. I stepped through in the ARM simulator and found the game was blowing up whenever I tried to register a function for Angelscript. Upon further inspection, I saw the AS_MAX_PORTABILITY #define was getting set, making it so I can only use the "generic" calling convention. I haven't written a lot of cross-platform code so I'm a newbie to thinking about different calling conventions, but from searching it looks to me as if ARM is supposed to be able to use CDECL function calls just fine.
Using #pragma messages I figured out where AS_MAX_PORTABILITY was getting defined. It's here in as_config.h:
#if (!defined(AS_X86) && !defined(AS_SH4) && !defined(AS_MIPS) && !defined(AS_PPC) && !defined(AS_PPC_64) && !defined(AS_XENON) && !defined(AS_X64_GCC) && !defined(AS_X64_MSVC) && !defined(AS_ARM) && !defined(AS_X64_MINGW))
#ifndef AS_MAX_PORTABILITY
#define AS_MAX_PORTABILITY
#endif
#endif
AS_MARMALADE is defined, but I realized that AS_ARM should probably also be defined, so I tried setting that in the project properties. Unfortunately when I do that, along with some probably-harmless warnings about ignoring stdcall, I get compiler errors:
1> Debug_AngelScript_new_vc10_gcc_arm/as_callfunc_arm.obj: In function `CallSystemFunctionNative(asCContext*, asCScriptFunction*, void*, unsigned long*, void*, unsigned long long&)':
1>
1>
1> d:/sebastian/games/marmalade/angelscript_new3/angelscript_marmalade/angelscript/source/as_callfunc_arm.cpp(126) : undefined reference to `armFuncR0'
1>
1>
1> d:/sebastian/games/marmalade/angelscript_new3/angelscript_marmalade/angelscript/source/as_callfunc_arm.cpp(130) : undefined reference to `armFunc'
1>
1>
1> d:/sebastian/games/marmalade/angelscript_new3/angelscript_marmalade/angelscript/source/as_callfunc_arm.cpp(134) : undefined reference to `armFuncR0'
1>
1>
1> d:/sebastian/games/marmalade/angelscript_new3/angelscript_marmalade/angelscript/source/as_callfunc_arm.cpp(142) : undefined reference to `armFuncR0R1'
1>
1>
1> d:/sebastian/games/marmalade/angelscript_new3/angelscript_marmalade/angelscript/source/as_callfunc_arm.cpp(147) : undefined reference to `armFuncR0'
1>
1>
1> d:/sebastian/games/marmalade/angelscript_new3/angelscript_marmalade/angelscript/source/as_callfunc_arm.cpp(155) : undefined reference to `armFuncR0R1'
1>
1>
1> d:/sebastian/games/marmalade/angelscript_new3/angelscript_marmalade/angelscript/source/as_callfunc_arm.cpp(159) : undefined reference to `armFuncObjLast'
1>
1>
1> d:/sebastian/games/marmalade/angelscript_new3/angelscript_marmalade/angelscript/source/as_callfunc_arm.cpp(162) : undefined reference to `armFuncR0ObjLast'
This doesn't make any sense, since the extern function definitions appear to be right there at the top of the document. I get that they reference assembler routines, but if anything went wrong there I would expect a linker error not a compiler error. I've fiddled around with as_config.h a little more but can't find the solution.
I feel like I'm stuck, since going any further would require fiddling around with the Angelscript source, in a place where I don't really fully understand how it works. Are there any ideas of what I can do to get Angelscript to run correctly when built for ARM? I am doing this game as part of a small sponsorship deal so I am on a really tight schedule. Worst case scenario, I can kludge this milestone by "pretending" Angelscript is being used; however it looks as though Andreas Jönsson peruses these forums somewhat frequently so I thought posting would be a good idea. I feel a little guilty asking for quick help from the creator of a library that's already very graciously offered for free... You have my word that, if the game makes any money, I'll be sure to make a nice donation on the AngelCode site :]
Thank you very much,
Sebastian