C preprocessor

Discussion in 'C Programming' started by mohdalibaig@gmail.com, Mar 30, 2007.

  1. Guest

    C preprocessor generates the expanded version of our source code. In
    order to view this expanded code, I made use of the command cpp
    filename.c on the dos prompt. This command generates a file of .I
    extension. What does this .I stands for? Although this file can be
    opened using any text editor.
     
    , Mar 30, 2007
    #1
    1. Advertising

  2. santosh Guest

    wrote:
    > C preprocessor generates the expanded version of our source code.


    Well, more precisely, the preprocessor is responsible for the
    translation phases one to four. The preprocessor need not be a
    seperate program, though it commonly is. The different phases of
    translation must seem to occur distinctly, though in actuality they
    may occur simultaneously or in any other order.

    > In
    > order to view this expanded code, I made use of the command cpp
    > filename.c on the dos prompt.


    Be aware that this command need not be available under all
    implementations, though again, it commonly is.

    > This command generates a file of .I
    > extension.


    Another implementation detail.

    > What does this .I stands for?


    It's a so called file name extension. Some systems requires them while
    under others they may be optional. Consult your implementation and
    system's documentation for the details.

    > Although this file can be
    > opened using any text editor.


    Yes. However the output of later phases of translation may not be
    human readable.
     
    santosh, Mar 30, 2007
    #2
    1. Advertising

  3. Mike Wahler Guest

    <> wrote in message
    news:...
    >C preprocessor generates the expanded version of our source code. In
    > order to view this expanded code, I made use of the command cpp
    > filename.c on the dos prompt. This command generates a file of .I
    > extension. What does this .I stands for?


    It stands for whatever your implementation's author wants it
    to stand for. My guess would be 'Intermediate'.

    > Although this file can be
    > opened using any text editor.


    Well, the output of a preprocessor is text.

    -Mike
     
    Mike Wahler, Mar 30, 2007
    #3
  4. Mike Wahler said:

    >
    > <> wrote in message
    > news:...
    >>C preprocessor generates the expanded version of our source code. In
    >> order to view this expanded code, I made use of the command cpp
    >> filename.c on the dos prompt. This command generates a file of .I
    >> extension. What does this .I stands for?

    >
    > It stands for whatever your implementation's author wants it
    > to stand for. My guess would be 'Intermediate'.
    >
    >> Although this file can be
    >> opened using any text editor.

    >
    > Well, the output of a preprocessor is text.


    I can find no such requirement in the Standard, which mandates only that
    "preprocessing tokens are converted into tokens" - which could easily
    be text, of course.

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
     
    Richard Heathfield, Mar 30, 2007
    #4
  5. Eric Sosman Guest

    Richard Heathfield wrote On 03/30/07 11:42,:
    > Mike Wahler said:
    >
    >
    >><> wrote in message
    >>news:...
    >>
    >>>C preprocessor generates the expanded version of our source code. In
    >>>order to view this expanded code, I made use of the command cpp
    >>>filename.c on the dos prompt. This command generates a file of .I
    >>>extension. What does this .I stands for?

    >>
    >>It stands for whatever your implementation's author wants it
    >>to stand for. My guess would be 'Intermediate'.
    >>
    >>
    >>>Although this file can be
    >>>opened using any text editor.

    >>
    >>Well, the output of a preprocessor is text.

    >
    >
    > I can find no such requirement in the Standard, which mandates only that
    > "preprocessing tokens are converted into tokens" - which could easily
    > be text, of course.


    I seem to recall (but only vaguely) an example of valid
    C source that could survive preprocessing only once: run it
    through the preprocessor and render it as text, and you got
    something that wouldn't compile, or compiled with a different
    meaning. Can't recall the details, but I think pp-numbers
    played a role somewhere. Anybody else remember this beast?

    --
     
    Eric Sosman, Mar 30, 2007
    #5
  6. Mike Wahler Guest

    "Richard Heathfield" <> wrote in message
    news:...
    > Mike Wahler said:
    >
    >>
    >> <> wrote in message
    >> news:...
    >>>C preprocessor generates the expanded version of our source code. In
    >>> order to view this expanded code, I made use of the command cpp
    >>> filename.c on the dos prompt. This command generates a file of .I
    >>> extension. What does this .I stands for?

    >>
    >> It stands for whatever your implementation's author wants it
    >> to stand for. My guess would be 'Intermediate'.
    >>
    >>> Although this file can be
    >>> opened using any text editor.

    >>
    >> Well, the output of a preprocessor is text.

    >
    > I can find no such requirement in the Standard, which mandates only that
    > "preprocessing tokens are converted into tokens" - which could easily
    > be text, of course.


    I should have known some pedant would jump in. :)

    Replying to OP's remark, "this file can be opened using any text editor,"
    I suppose I should have said "apparently the output of your preprocessor
    is text."

    -Mike
     
    Mike Wahler, Mar 30, 2007
    #6
  7. Mike Wahler said:

    >
    > "Richard Heathfield" <> wrote in message
    > news:...
    >> Mike Wahler said:
    >>

    <snip>

    >>> Well, the output of a preprocessor is text.

    >>
    >> I can find no such requirement in the Standard, which mandates only
    >> that "preprocessing tokens are converted into tokens" - which could
    >> easily be text, of course.

    >
    > I should have known some pedant would jump in. :)


    Aye, you should. :)

    > Replying to OP's remark, "this file can be opened using any text
    > editor," I suppose I should have said "apparently the output of your
    > preprocessor is text."


    Still not quite right, since in normal circumstances the output of his
    preprocessor is very likely *not* text. How about this? "If your
    implementation supports an option to provide you with the result of
    preprocessing your C code, it is very likely to do so in text format."

    --
    Richard Heathfield
    "Usenet is a strange place" - dmr 29/7/1999
    http://www.cpax.org.uk
    email: rjh at the above domain, - www.
     
    Richard Heathfield, Mar 30, 2007
    #7
  8. Eric Sosman wrote:
    > Richard Heathfield wrote On 03/30/07 11:42,:
    > > Mike Wahler said:
    > >
    > >
    > >><> wrote in message
    > >>news:...
    > >>
    > >>>C preprocessor generates the expanded version of our source code. In
    > >>>order to view this expanded code, I made use of the command cpp
    > >>>filename.c on the dos prompt. This command generates a file of .I
    > >>>extension. What does this .I stands for?
    > >>
    > >>It stands for whatever your implementation's author wants it
    > >>to stand for. My guess would be 'Intermediate'.
    > >>
    > >>
    > >>>Although this file can be
    > >>>opened using any text editor.
    > >>
    > >>Well, the output of a preprocessor is text.

    > >
    > >
    > > I can find no such requirement in the Standard, which mandates only that
    > > "preprocessing tokens are converted into tokens" - which could easily
    > > be text, of course.

    >
    > I seem to recall (but only vaguely) an example of valid
    > C source that could survive preprocessing only once: run it
    > through the preprocessor and render it as text, and you got
    > something that wouldn't compile, or compiled with a different
    > meaning. Can't recall the details, but I think pp-numbers
    > played a role somewhere. Anybody else remember this beast?


    The output format by different preprocessors is different, and some
    will make sure to that /any/ valid program's preprocessor output will
    be re-read exactly the same. A program that may fail if preprocessor
    output is saved in text format is

    #include <stdio.h>
    #define M(x) x
    #define S(x) T(x), x
    #define T(x) #x
    int main(void) {
    int zero = 0;
    printf("%s = %d\n", S(M(+)M(+)zero));
    return zero;
    }
     
    =?utf-8?B?SGFyYWxkIHZhbiBExLNr?=, Mar 30, 2007
    #8
  9. Eric Sosman Guest

    Harald van Dijk wrote On 03/30/07 15:20,:
    > Eric Sosman wrote:
    >
    >>Richard Heathfield wrote On 03/30/07 11:42,:
    >>
    >>>Mike Wahler said:
    >>>
    >>>
    >>>
    >>>><> wrote in message
    >>>>news:...
    >>>>
    >>>>
    >>>>>C preprocessor generates the expanded version of our source code. In
    >>>>>order to view this expanded code, I made use of the command cpp
    >>>>>filename.c on the dos prompt. This command generates a file of .I
    >>>>>extension. What does this .I stands for?
    >>>>
    >>>>It stands for whatever your implementation's author wants it
    >>>>to stand for. My guess would be 'Intermediate'.
    >>>>
    >>>>
    >>>>
    >>>>>Although this file can be
    >>>>>opened using any text editor.
    >>>>
    >>>>Well, the output of a preprocessor is text.
    >>>
    >>>
    >>>I can find no such requirement in the Standard, which mandates only that
    >>>"preprocessing tokens are converted into tokens" - which could easily
    >>>be text, of course.

    >>
    >> I seem to recall (but only vaguely) an example of valid
    >>C source that could survive preprocessing only once: run it
    >>through the preprocessor and render it as text, and you got
    >>something that wouldn't compile, or compiled with a different
    >>meaning. Can't recall the details, but I think pp-numbers
    >>played a role somewhere. Anybody else remember this beast?

    >
    >
    > The output format by different preprocessors is different, and some
    > will make sure to that /any/ valid program's preprocessor output will
    > be re-read exactly the same. A program that may fail if preprocessor
    > output is saved in text format is
    >
    > #include <stdio.h>
    > #define M(x) x
    > #define S(x) T(x), x
    > #define T(x) #x
    > int main(void) {
    > int zero = 0;
    > printf("%s = %d\n", S(M(+)M(+)zero));
    > return zero;
    > }


    That wasn't it ... Hmmm <spends too much googletime> Aha!
    It was a thread from three years ago

    http://groups.google.com/group/comp.lang.c/msg/5efee5801b14df99

    ... and I recalled imperfectly: It was an invalid source that
    became valid after preprocessing (the original was uncompilable
    but the preprocessor output was compilable, not the other way
    around), and pp-numbers had nothing to do with it. The original

    #define CAT(a,b) a##b
    #define COMMENT CAT(/,/)
    COMMENT This is a comment

    ... didn't compile, but the (non-mandated) preprocessed text

    // This is a comment

    ... was perfectly valid.

    --
     
    Eric Sosman, Mar 30, 2007
    #9
    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. Chris P
    Replies:
    0
    Views:
    443
    Chris P
    Oct 28, 2003
  2. The Weiss Family

    VHDL Preprocessor

    The Weiss Family, Jul 14, 2004, in forum: VHDL
    Replies:
    2
    Views:
    3,243
    The Weiss Family
    Jul 14, 2004
  3. =?Utf-8?B?SSBhbSBTYW0=?=

    C# Preprocessor

    =?Utf-8?B?SSBhbSBTYW0=?=, Mar 13, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,586
    =?Utf-8?B?SSBhbSBTYW0=?=
    Mar 13, 2005
  4. Replies:
    0
    Views:
    2,696
  5. Cronus
    Replies:
    1
    Views:
    693
    Paul Mensonides
    Jul 15, 2004
Loading...

Share This Page