Recompiling dll's and adding more during run time - what are my options?
<p>I want to compile custom functions during run time based on user written scripts. I'll give a hypothetical example that should demonstrate exactly what I need to do. This is the best way for me to describe the problem. I'd like a little input/ideas in how I can solve this. At the bottom I give you my ideas.</p>

<p>I have 2 classes, one with public int x and y. Another with public int x,y,z. There can be more than one instance of each class running.</p>

<p>The thing with these classes though (and here comes my problem) is that they need to be updatable via a user written and then compiled function during run time, that then gets added to a list of update functions that gets run once per cycle/event. Which could be at the touch of some button or something.</p>

<p>Example: The user has written a script to update the public members of Class A. He has written A.X = B.Y + C.Z. The variables here are public, never private. This method needs to be compiled, and added to some list of functions to call each cycle. Obviously this method needs access to class B and C, as well as A. So pointers to those need to be passed in. The function returns nothing.</p>

<p>When I say class A, B, and C. I mean these as some instances of any classes. 'A' could be class Q, while both B and C could be from class T. Or any other variation. These classes do not need recompilation/user written or anything like that.</p>

<p>I just need help with coming up with options and how to compile a function that gets passed in some pointers and does something with them. But with all of that defined run time, what the function does, what gets passed into it, ect. </p>

<p>---- What I think I can do ---</p>

<p>I'm jumping extremely far in knowledge but it is what I always do. So I am just switching from C# to C++ and have little to go on for now while I know little. So all i can do is guess solutions and research them. I'm guessing I could compile a late loading dll for each function, and I'm guessing the dll has to know something about the data structures passed into it so I think it could work to have them in a separate normal dll usable by any program. (The A,B, and C class thingies, or rather Q, and T classes which A,B,and C were instances of in my little demo). So now both the normal program and the dll functions knows all about the classes, and all I have to do is compile the dlls during runtime, load them, and somehow get a pointer to them that my main application has and can call with the appropriate arguments. Then if the user changes the script, the dll unloads, recompiles, loads again, and a new pointer is gotten?</p>

<p>Any help is greatly appreciated. If you can help direct my learning/research I'll learn a lot faster and be able to implement this. Thank you so much!</p>
