October 16th, 2013, 01:10 AM
"Puppet Program" Question
I have a concise question. I have a semantically correct code in a program file (foo.c). I have a semantically correct function in a header file (bar.h). The header file is not included in foo.c.
Is there a known way to code a function in foo.c that can take in information regarding the function in bar.h, the function code itself, and use that information to execute all of the operations carried out by the function in bar.h without any pre-existing knowledge of what the code is exactly for the function in bar.h?
Basically the goal is to have code in foo.c -- which has the code for the function in bar.h stored in a string -- generate the same activity as a version of foo.c in which the the code contains the function in bar.h.
So I am asking if you all know of a way to have the function receive the code for the function in bar.h and carry out the same operations that are carried out by the function in bar.h.
Any solution at all that allows a person to have a running program execute code input by a user would be appreciated.
October 16th, 2013, 03:07 AM
No, nothing of the kind.
H-files are simply included into your C-code files before compilation, so of course you can do nothing in runtime.
C is not kind of a "scripting" language which allows to modify and execute its statements at runtime.