Including files at run time

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2006
Posts: 514
Reputation: Jishnu will become famous soon enough Jishnu will become famous soon enough 
Solved Threads: 26
Jishnu's Avatar
Jishnu Jishnu is offline Offline
Posting Pro

Re: Including files at run time

 
0
  #11
Dec 21st, 2007
You can not include header file as such during runtime.
Aw, that makes me feel sad

There are other ways to include code at runtime like load dlls, but to answer your question you cannot include header file as such on the fly.
If that is the case, then I'd appreciate if you list some methods to do it beyond the premices of C.
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.

"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 176
Reputation: dubeyprateek is an unknown quantity at this point 
Solved Threads: 22
dubeyprateek's Avatar
dubeyprateek dubeyprateek is offline Offline
Junior Poster

Re: Including files at run time

 
0
  #12
Dec 21st, 2007
You can build static libraries and dynamic libraries and load them in your application. However, it is more platform specific than language specific.

You can use COM and point to right implementation of the function (rather interface).

There are many ways to achieve an objective, You need to select one which suits best to you.
Aw, that makes me feel sad
Don't worry; Not only you but no one can include header files during run time .
Just chuck the purpose; “#include” is a PREPROCESSOR directive. You would like to include header file even before you start compilation.
Last edited by dubeyprateek; Dec 21st, 2007 at 11:01 am.
I know I am. Therefore I am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 514
Reputation: Jishnu will become famous soon enough Jishnu will become famous soon enough 
Solved Threads: 26
Jishnu's Avatar
Jishnu Jishnu is offline Offline
Posting Pro

Re: Including files at run time

 
0
  #13
Dec 21st, 2007
However, it is more platform specific than language specific.
I'd like to start off with the most language specific and the least platform specific way.

Just chuck the purpose; “#include” is a PREPROCESSOR directive. You would like to include header file even before you start compilation.
In that case, I'd rather reframe my question to: How can I select which function to execute at run time, all alternatives being stored in different files

There are many ways to achieve an objective, You need to select one which suits best to you.
Suppose I want to search for such methods, what keywords should I use?
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.

"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 176
Reputation: dubeyprateek is an unknown quantity at this point 
Solved Threads: 22
dubeyprateek's Avatar
dubeyprateek dubeyprateek is offline Offline
Junior Poster

Re: Including files at run time

 
0
  #14
Dec 21st, 2007
Use pure virtual functions (run time polymorphism C++).
Or call functions in if else or switch blocks.

Suppose I want to search for such methods, what keywords should I use?
You can not surch or enamurate all functions of a executable.
Last edited by dubeyprateek; Dec 21st, 2007 at 12:43 pm.
I know I am. Therefore I am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 514
Reputation: Jishnu will become famous soon enough Jishnu will become famous soon enough 
Solved Threads: 26
Jishnu's Avatar
Jishnu Jishnu is offline Offline
Posting Pro

Re: Including files at run time

 
0
  #15
Dec 21st, 2007
You can not surch or enamurate all functions of a executable.
You misunderstood me. I'm talking about methods to achieve what I want. I'm not using the word methods in the sense of functions.
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.

"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 176
Reputation: dubeyprateek is an unknown quantity at this point 
Solved Threads: 22
dubeyprateek's Avatar
dubeyprateek dubeyprateek is offline Offline
Junior Poster

Re: Including files at run time

 
1
  #16
Dec 21st, 2007
You can use component object modeling, runtime polymorphism, Pure virtual functions.

Dlls (Dynamicly linked library)

Thanks,
Prateek
I know I am. Therefore I am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,471
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1477
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: Including files at run time

 
0
  #17
Dec 21st, 2007
I think it would help everyone to understand if you would provide some examples. Do you need functions to display information in different languages, such as English, German, French etc.? You create a language DLL for each language you want to support then install the desired language dll when you install the rest of the program. I'm certain you must have seen this before when you try to install something that other people have written.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 514
Reputation: Jishnu will become famous soon enough Jishnu will become famous soon enough 
Solved Threads: 26
Jishnu's Avatar
Jishnu Jishnu is offline Offline
Posting Pro

Re: Including files at run time

 
0
  #18
Dec 22nd, 2007
Actually I've coded a common interface for a two-player fighting (strategy-based) game. Now, The strategy (technically speaking, A.I.) code has to be written by the players in separate files. I thought I'd include those two files at runtime (because there would be many strategy files, each of them numbered) in my main code to start the game.

Thank you all for your replies .

As this approach won't work, I'd appreciate if you show me some another way of doing the same thing in C.
Last edited by Jishnu; Dec 22nd, 2007 at 5:30 am.
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.

"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,953
Reputation: Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of Duoas has much to be proud of 
Solved Threads: 214
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: Including files at run time

 
0
  #19
Dec 23rd, 2007
Use DLLs like AD suggested. Instead of supplying a language it should supply an AI. The functions will be the same for each AI DLL, so the only variable will be the name of the DLL opened with LoadLibrary().
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 269
Reputation: sarehu is on a distinguished road 
Solved Threads: 22
sarehu's Avatar
sarehu sarehu is offline Offline
Posting Whiz in Training

Re: Including files at run time

 
0
  #20
Dec 23rd, 2007
If this is turn-based, the cleanest way to do this is with pipes. Have the AI programs communicate over stdin and stdout, and have the main program fork processes and setup pipes and launch the AI programs with the pipes tied to stdin and stdout. That way (also) you don't have to worry about AI programs going and reading/writing to strange places in memory in an attempt to disrupt the opponent's AI.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC