Hi, Ive 2 programs at different memory locations. I wish to execute the 2nd program in the 1st by using a function pointer ( int *(funcptr()) in the 1st program by passing the address of the main function in 2nd program by address value rather than by function name. Each time im getting a conversion error. How best can I go about this? How can I also access ALL the contents of disc and input in the stream for displaying on the screen.
Memory handling
Collapse
X
-
What platform are you using because
Ive 2 programs at different memory locations.
If that is true then knowing the location of main is unlikely to help because calling main will not initialise all the program data to the correct values, you need to know the location of the entry-point code for the program.
On an embedded platform if you know this then it is eminently possible to run one program from another, I know because I have done it. However it is dependent on the platform making it possible and it is definitely not possible on a PC platform.
You say you are getting a conversion error passing the address of the function. I would have to ask if you have your data types correct. It is completely conceivable, and standard compliant, for instance that a pointer to data would be completely unable to hold a pointer to code. For example if the platform had a Harvard Architecture then code and data have completely separate address spaces.
In short what you are attempting is possible of the right platforms, but not PCs, but it is hard for us to provide further help without more detail:
- What is the platform?
- What is the code where the address of the main(2) is received and the code where that address is used and the code lines that are producing errors?
- What are the actual errors being produced?
- What is your tool-chain?
Comment
Comment