|
-
June 16th, 2009, 11:54 PM
#2
Re: Use Function from text file
Not in the way your question implies.
What I infer is that you mean to compile C++ code from a text file and then execute the result from within a C++ program. There's no practical way to do that. The primary reason is that it is the operating system's job to keep you from "executing" RAM which is been allocated from the heap or on the stack which was not previously 'blessed' by the operating system as code. There are 'tricks' you can pull, but the act is prone to trouble and quite likely the origin of security vulnerabilities.
What you can do, however, is to incorporate the facility of another runtime language from within C++. There are libraries that allow you to accept code from users in Python, Java, Ruby or other languages like them, such that the user can supply code for execution from within your application. This is similar to what MS did for Visual Basic for Applications, what Javascript is for web pages, what LISP is for AutoCAD, etc. The subject is too vast and the options too wide to detail here, and I have no links beyond what you would find with Google on the subject. However, the general idea is that you're incorporating an interpreter/runtime in your application that can load code for the runtime from a file.
Last edited by JVene; June 17th, 2009 at 10:12 AM.
If my post was interesting or helpful, perhaps you would consider clicking the 'rate this post' to let me know (middle icon of the group in the upper right of the post).
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|