Skip to main content
gamedev.net
🔒 Locked

Dynamic Function Calls and Creation

Started by HappyDude 2 replies 350+ views
Original Post
HappyDude
HappyDude
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 .
Arild Fines
Arild Fines
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.
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
HappyDude
HappyDude
Heh, I guess that makes sense... so the only languages that could do that would be interpretted ones rather than compiled .
jenova
jenova
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.
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.