how to do two-stage preprocessing of one file

Discussion in 'C Programming' started by andreyvul, Nov 12, 2007.

  1. andreyvul

    andreyvul Guest

    What I'm trying to do is have the preprocessor parse one file twice.
    The file has three parts, and each is dependent on the previous.
    Example (file name is foo.c):
    #ifndef ONCE /* first part */
    #define D #define
    #define ONCE
    #include "foo.c"
    #endif
    #ifdef ONCE /* second part */
    D x int
    #ifndef TWICE
    #define TWICE
    #include "foo.c"
    #endif
    #endif
    #ifdef TWICE /* third part */
    x y;
    #endif

    The problem is that the preprocessor just adds the third part to the
    second part, but doesn't preprocess the third part in the process.
    How do I make my #includes and #ifedefs so that the third part will be
    preprocessed?
    andreyvul, Nov 12, 2007
    #1
    1. Advertising

  2. andreyvul

    santosh Guest

    In article <>,
    andreyvul <> wrote on Tuesday 13 Nov 2007 5:08 am:

    > What I'm trying to do is have the preprocessor parse one file twice.
    > The file has three parts, and each is dependent on the previous.
    > Example (file name is foo.c):
    > #ifndef ONCE /* first part */
    > #define D #define
    > #define ONCE
    > #include "foo.c"
    > #endif
    > #ifdef ONCE /* second part */
    > D x int
    > #ifndef TWICE
    > #define TWICE
    > #include "foo.c"
    > #endif
    > #endif
    > #ifdef TWICE /* third part */
    > x y;
    > #endif
    >
    > The problem is that the preprocessor just adds the third part to the
    > second part, but doesn't preprocess the third part in the process.
    > How do I make my #includes and #ifedefs so that the third part will be
    > preprocessed?
    santosh, Nov 13, 2007
    #2
    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. Anoops
    Replies:
    1
    Views:
    620
    navneetcertain
    Aug 1, 2013
  2. Anoops
    Replies:
    0
    Views:
    510
    Anoops
    Sep 9, 2005
  3. Brian Folke Seaberg

    Initialization -- One Stage or Two Stage

    Brian Folke Seaberg, Jan 4, 2005, in forum: C++
    Replies:
    4
    Views:
    713
    Howard
    Jan 4, 2005
  4. andreyvul

    how to do two-stage preprocessing of one file

    andreyvul, Nov 12, 2007, in forum: C Programming
    Replies:
    11
    Views:
    483
    Ark Khasin
    Nov 13, 2007
  5. Pedro Graca

    calculations in the preprocessing stage

    Pedro Graca, Feb 18, 2008, in forum: C Programming
    Replies:
    6
    Views:
    283
    Ben Bacarisse
    Feb 19, 2008
Loading...

Share This Page