#include header

Discussion in 'C++' started by clinisbut, Apr 11, 2008.

  1. clinisbut

    clinisbut Guest

    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...
     
    clinisbut, Apr 11, 2008
    #1
    1. Advertising

  2. clinisbut

    Looney Guest

    clinisbut wrote:

    > 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.
     
    Looney, Apr 11, 2008
    #2
    1. Advertising

  3. On Apr 11, 8:59 pm, clinisbut <> wrote:
    > 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
     
    Alexander Dong Back Kim, Apr 11, 2008
    #3
  4. clinisbut

    James Kanze Guest

    On 11 avr, 22:10, "Robbie Hatley"
    <> 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:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Apr 12, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Danny Anderson
    Replies:
    5
    Views:
    508
    Victor Bazarov
    Aug 15, 2003
  2. Rolf Magnus
    Replies:
    2
    Views:
    606
    Karl Heinz Buchegger
    Nov 28, 2003
  3. Aguilar, James
    Replies:
    2
    Views:
    691
    Aguilar, James
    Jul 16, 2004
  4. Andreas Bogenberger
    Replies:
    3
    Views:
    936
    Andreas Bogenberger
    Feb 22, 2008
  5. mlt
    Replies:
    2
    Views:
    853
    Jean-Marc Bourguet
    Jan 31, 2009
Loading...

Share This Page