Re: #include header
On 11 avr, 22:10, "Robbie Hatley"
<see.my.signat...@for.my.email.address> wrote:
"clinisbut" asked:
[...]
What I'm trying to do is load this files at user interact.
I don't know If there is a way to automatically like JSON with
javascript...
You can't "#include" a file at run-time, or even at compile
time, because "#include" is a preprocessor directive which runs
BEFORE the compiler is invoked.
Just a nit, but that's not true. The term "preprocessor" is
used for historical reasons---in the case of the first C
compilers, it was a separate program. But this had stopped
being the case even before C was standardized, and in the C
standard (and in C++, which followed), the preprocessor is part
of the compiler.
[...]
You can't alter a C++ program on-the-fly at run-time, though,
because C++ is a compiled language; the compiled machine language
program is fixed.
Sort of. All of the implementations I know support dynamic
linking, so you could invoke the compiler on the C++ sources to
build a dynamic object, then link it.
It's not a route I'd like to take, however.
There ARE various ways of changing program behavior at runtime,
though. These include:
1. Command-line switches
2. User input, either console or GUI
3. ini files (program reads file at runtime and alters behavior)
4. registry entries (if MS Windows)
5. DLL files (if your compiler supports them)
In many cases, I'll define a small, simple language myself, and
implement an interpretor for it. If the targetted functionality
is simple enough and specialized enough, it's not very
difficult.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34