#include header

C

clinisbut

may be i'm asking a stupid question, but, is it possible to include a
header file at runtime??

I have some header files with this inside:

{{12, 16},{
0x00,0x00, /* ................ */
0x00,0x00, /* ................ */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x00,0x00, /* ................ */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x00,0x00, /* ................ */
0x00,0x00, /* ................ */
0x00,0x00, /* ................ */
0x00,0x00, /* ................ */
0x00,0x00 /* ................ */
}}

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

Looney

clinisbut said:
may be i'm asking a stupid question, but, is it possible to include a
header file at runtime??

I have some header files with this inside:

{{12, 16},{
0x00,0x00, /* ................ */
0x00,0x00, /* ................ */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x00,0x00, /* ................ */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x00,0x00, /* ................ */
0x00,0x00, /* ................ */
0x00,0x00, /* ................ */
0x00,0x00, /* ................ */
0x00,0x00 /* ................ */
}}

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

In C/C++, code needs compilation after headers are included as they
change the meaning of a translation unit.
So No you can not include headers at runtime, unless u are
implementing some sort of a code generator or compiler which accepts
code from you and compiles it into an application, wait a minute there
are allready applications which do that called compilers.
 
A

Alexander Dong Back Kim

may be i'm asking a stupid question, but, is it possible to include a
header file at runtime??

I have some header files with this inside:

{{12, 16},{
0x00,0x00, /* ................ */
0x00,0x00, /* ................ */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x00,0x00, /* ................ */
0x33,0x30, /* ..%%..%%..%%.... */
0x33,0x30, /* ..%%..%%..%%.... */
0x00,0x00, /* ................ */
0x00,0x00, /* ................ */
0x00,0x00, /* ................ */
0x00,0x00, /* ................ */
0x00,0x00 /* ................ */

}}

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

Hi there,

Is that the syntax based on C/C++ programming language? I can see it
seems like a kind of array. How about using data file instead?

I may be barking on the wrong tree :p since I can't understand what
the array like thing for.

Cheers,
Alex Kim
 
J

James Kanze

"clinisbut" asked:

[...]
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top