For example, instead of doing this:
struct MyStruct {int a; int b; char *c;} extern "C" __declspec(dllexport) char *MyFunc(int n, char *v[]) { if(n != 3) return "Error, invalid arguments"; char *arg1 = v[0]; int arg2 = atoi(v[1]); MyStruct *arg3 = StringToMyStruct(v[2]); ... }
call("mydll.dll","_MyFunc")(myString, num2text(myNum), MyStructToString(myStruct))
arguments would be passed like this:
struct MyStruct {int a; int b; char *c;} extern "C" __declspec(dllexport) char *MyFunc(int n, char *arg1, int arg2, MyStruct *arg3) { if(n != 3) return "Error, invalid arguments"; ... }
call("mydll.dll","_MyFunc")(myString, myNum, myStruct)
(The first argument N would still be necessary because otherwise the DLL doesn't know if some arguments are missing)
The main advantage of this would be the ability to call system DLLs/.so's without writing wrappers.