Re: Expand macro's

Discussion in 'C++' started by MiniDisc_2k2, Jul 22, 2003.

  1. MiniDisc_2k2

    MiniDisc_2k2 Guest

    "Darius Blaszijk" <> wrote in message
    news:3f1d3ccd$0$12356$...
    > Hi there,
    >
    > I was wondering if there is something like a tool that does expand all
    > macro's from a project?? User defined and preferrably system macro's. Ok,

    I
    > know that the preprocessor does the same, but is there such a tool without
    > having to use the bulky preprocessor. Or if this is not possible, how can

    I
    > use the preprocessor to expand a project for me?? Please spell it out for
    > me, as I'm only a beginner in C. I use DJGPP as a compiler.
    >
    > Kind regards, Darius Blaszijk
    >
    >


    That depends. What do you mean by "expand?" The preprocessor expands those
    macros so that the compiler can compile your code without macros, but does
    not modify your source code. If you want your actual source code to be
    expanded so that you can see the expanded code, well, I'll get back to you
    on that part...

    --
    MiniDisc_2k2

    P.S. The preprocessor is part of the compiler; it will automatically expand
    your macros. Or at least it's part of my compiler...
     
    MiniDisc_2k2, Jul 22, 2003
    #1
    1. Advertising

  2. Hi MiniDisc_2k2,

    Yes, my aim is to expand it so I can actually see whats ultimately going to
    be compiled.

    Darius Blaszijk

    MiniDisc_2k2 <> schreef in berichtnieuws
    i9bTa.860$5b7.494@lakeread01...
    >
    > "Darius Blaszijk" <> wrote in message
    > news:3f1d3ccd$0$12356$...
    > > Hi there,
    > >
    > > I was wondering if there is something like a tool that does expand all
    > > macro's from a project?? User defined and preferrably system macro's.

    Ok,
    > I
    > > know that the preprocessor does the same, but is there such a tool

    without
    > > having to use the bulky preprocessor. Or if this is not possible, how

    can
    > I
    > > use the preprocessor to expand a project for me?? Please spell it out

    for
    > > me, as I'm only a beginner in C. I use DJGPP as a compiler.
    > >
    > > Kind regards, Darius Blaszijk
    > >
    > >

    >
    > That depends. What do you mean by "expand?" The preprocessor expands those
    > macros so that the compiler can compile your code without macros, but does
    > not modify your source code. If you want your actual source code to be
    > expanded so that you can see the expanded code, well, I'll get back to you
    > on that part...
    >
    > --
    > MiniDisc_2k2
    >
    > P.S. The preprocessor is part of the compiler; it will automatically

    expand
    > your macros. Or at least it's part of my compiler...
    >
    >
     
    Darius Blaszijk, Jul 22, 2003
    #2
    1. Advertising

  3. On 22/7/03 2:42 pm (UK time), Darius Blaszijk let loose these words:

    > Hi MiniDisc_2k2,
    >
    > Yes, my aim is to expand it so I can actually see whats ultimately going to
    > be compiled.

    <snip top of upside-down reply>

    That's exactly what a preprocessor is for. This might be a tool
    somewhere called CPP (that stands for C PreProcessor, not C++ in this
    context) or something similar. Alternatively, it might be a command
    line option of the compiler program itself.

    Stewart.

    --
    My e-mail is valid but not my primary mailbox. Please keep replies on
    on the 'group where everyone may benefit.
     
    Stewart Gordon, Jul 22, 2003
    #3
  4. On Tue, 22 Jul 2003, Stewart Gordon wrote:
    >
    > On 22/7/03 2:42 pm (UK time), Darius Blaszijk let loose these words:
    > >
    > > Yes, my aim is to expand it so I can actually see whats ultimately going to
    > > be compiled.

    > <snip top of upside-down reply>
    >
    > That's exactly what a preprocessor is for. This might be a tool
    > somewhere called CPP (that stands for C PreProcessor, not C++ in this
    > context) or something similar. Alternatively, it might be a command
    > line option of the compiler program itself.


    Or occasionally both. The particular vagaries of a particular
    compiler system are not topical here.

    <OT>

    I happen to know that DJGPP includes the command-line tool 'cpp';
    use the command line cpp -P myfile.c to expand your macros.
    Beware that this will also give you the complete text of any
    header files you include, so if you don't care about the internals
    of DJGPP's <stdio.h> and whatnot, snip those before running it.

    </OT>

    -Arthur
     
    Arthur J. O'Dwyer, Jul 22, 2003
    #4
  5. On 22/7/03 4:29 pm (UK time), Arthur J. O'Dwyer let loose these words:

    <OT>

    <snip>
    > I happen to know that DJGPP includes the command-line tool 'cpp';
    > use the command line cpp -P myfile.c to expand your macros.
    > Beware that this will also give you the complete text of any
    > header files you include, so if you don't care about the internals
    > of DJGPP's <stdio.h> and whatnot, snip those before running it.


    But then you won't get expansions of the macros defined in that branch
    of the inclusion tree.

    </OT>

    Stewart.

    --
    My e-mail is valid but not my primary mailbox. Please keep replies on
    on the 'group where everyone may benefit.
     
    Stewart Gordon, Jul 22, 2003
    #5
    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. Victor Bazarov

    Re: Expand macro's

    Victor Bazarov, Jul 22, 2003, in forum: C++
    Replies:
    0
    Views:
    414
    Victor Bazarov
    Jul 22, 2003
  2. Guy Harrison

    Re: Expand macro's

    Guy Harrison, Jul 22, 2003, in forum: C++
    Replies:
    0
    Views:
    374
    Guy Harrison
    Jul 22, 2003
  3. sathyashrayan

    pls expand this macro

    sathyashrayan, Oct 30, 2005, in forum: C Programming
    Replies:
    8
    Views:
    425
    Simon Biber
    Oct 31, 2005
  4. Fabrice
    Replies:
    12
    Views:
    553
    Keith Thompson
    Nov 1, 2007
  5. Doug .

    C macro to expand struct types?

    Doug ., Jul 1, 2011, in forum: C Programming
    Replies:
    1
    Views:
    1,224
    Shao Miller
    Jul 3, 2011
Loading...

Share This Page