943,733 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2407
  • C RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Dec 21st, 2007
0

Re: Including files at run time

Quote ...
You can not include header file as such during runtime.
Aw, that makes me feel sad

Quote ...
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.
Reputation Points: 193
Solved Threads: 25
Posting Pro
Jishnu is offline Offline
518 posts
since Oct 2006
Dec 21st, 2007
0

Re: Including files at run time

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.
Quote ...
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.
Reputation Points: 39
Solved Threads: 24
Junior Poster
dubeyprateek is offline Offline
176 posts
since Mar 2006
Dec 21st, 2007
0

Re: Including files at run time

Quote ...
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.

Quote ...
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

Quote ...
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?
Reputation Points: 193
Solved Threads: 25
Posting Pro
Jishnu is offline Offline
518 posts
since Oct 2006
Dec 21st, 2007
0

Re: Including files at run time

Use pure virtual functions (run time polymorphism C++).
Or call functions in if else or switch blocks.

Quote ...
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.
Reputation Points: 39
Solved Threads: 24
Junior Poster
dubeyprateek is offline Offline
176 posts
since Mar 2006
Dec 21st, 2007
0

Re: Including files at run time

Quote ...
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.
Reputation Points: 193
Solved Threads: 25
Posting Pro
Jishnu is offline Offline
518 posts
since Oct 2006
Dec 21st, 2007
1

Re: Including files at run time

You can use component object modeling, runtime polymorphism, Pure virtual functions.

Dlls (Dynamicly linked library)

Thanks,
Prateek
Reputation Points: 39
Solved Threads: 24
Junior Poster
dubeyprateek is offline Offline
176 posts
since Mar 2006
Dec 21st, 2007
0

Re: Including files at run time

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Dec 22nd, 2007
0

Re: Including files at run time

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.
Reputation Points: 193
Solved Threads: 25
Posting Pro
Jishnu is offline Offline
518 posts
since Oct 2006
Dec 23rd, 2007
0

Re: Including files at run time

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().
Featured Poster
Reputation Points: 1140
Solved Threads: 229
Postaholic
Duoas is offline Offline
2,039 posts
since Oct 2007
Dec 23rd, 2007
0

Re: Including files at run time

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.
Reputation Points: 98
Solved Threads: 22
Posting Whiz in Training
sarehu is offline Offline
269 posts
since Oct 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: execl() to copy a file /bin/cp
Next Thread in C Forum Timeline: syntax question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC