Archived

This topic is now archived and is closed to further replies.

HappyDude

Dynamic Function Calls and Creation

Recommended Posts

Two questions, both about dynamic function stuff in C++. 1) Is it possible to create a function dynamically? 2) Are there any functions or is there any way to call a function by simply using it''s name? By this I mean, some kind of function where I can pass a string, the string containing the name of the function I want called, which then executes that function? I believe in VB6 the CallByName function does that, although don''t quote me on that because I don''t really know VB that well... just heard it from someone else. If anyone can help me with those, it would be extremely helpful .

Share this post


Link to post
Share on other sites
C++ has no reflection capabilities to speak of - nor can it create code dynamically(would be a bit hard to implement, since you would have to invoke the compiler).

Once there was a time when all people believed in God and the church ruled. This time is called the Dark Ages.

Share this post


Link to post
Share on other sites
actually in the Win32 environment you can allocate memory using "VirtualAlloc" and make it an executable segment. at this point you can fill this memory block with instructions and then jump to this segment. however, your knowledge of assembler should be "advanced". this is how i implement dynamic compilation for my MIPS RISC processor emulator.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

Share this post


Link to post
Share on other sites