Preprocessor question

Discussion in 'C Programming' started by Mateusz_madi, Jul 31, 2011.

  1. Mateusz_madi

    Mateusz_madi Guest

    Hi all, I have question about preprocessor. I fi have a program called
    binary_s.c and i put it only on preprocessor like:
    cc -E binary_s.c and i get strange output at the beginning of file
    like:

    # 1 "binary_s.c"
    # 1 "<built-in>"
    # 1 "<command-line>"
    # 1 "binary_s.c"

    What are those if I didn't included any libaries ?

    Regards,
    Mateusz
    Mateusz_madi, Jul 31, 2011
    #1
    1. Advertising

  2. Mateusz_madi <> writes:

    > Hi all, I have question about preprocessor. I fi have a program called
    > binary_s.c and i put it only on preprocessor like:
    > cc -E binary_s.c and i get strange output at the beginning of file
    > like:
    >
    > # 1 "binary_s.c"
    > # 1 "<built-in>"
    > # 1 "<command-line>"
    > # 1 "binary_s.c"
    >
    > What are those if I didn't included any libaries ?


    These are internal to the implementation (gcc, from the look of it).
    The implementation can make the result of running only the preprocessor
    almost anything it likes since the C standard does not mandate anything
    but the overall effect of translating a program. However, most
    implementations try to make the output of the preprocessor valid C. The
    standard permits almost anything after a # and most implementations take
    advantage of this to do keep track of information they might need later
    on in the translation process.

    In this case, the lines record the position in the stream of tokens that
    is being processed (mainly for error reporting). For example, if you
    had -include x.h on the command line, any tokens resulting from it would
    have appeared between the 3rd and 4th lines of you example (together
    with a further '#' line to note the new file being processed). Any
    errors in x.h can then be noted as coming from "x.h included from
    command-line" or some such text.

    --
    Ben.
    Ben Bacarisse, Jul 31, 2011
    #2
    1. Advertising

  3. Mateusz_madi

    Gene Guest

    On Jul 31, 7:16 am, Mateusz_madi <> wrote:
    > Hi all, I have question about preprocessor. I fi have a program called
    > binary_s.c and i put it only on preprocessor like:
    > cc -E binary_s.c and i get strange output at the beginning of file
    > like:
    >
    > # 1 "binary_s.c"
    > # 1 "<built-in>"
    > # 1 "<command-line>"
    > # 1 "binary_s.c"


    The Preprocessor Output section of the Gnu CPP manual answers your
    question in detail for gcc. There also this in case you want to get
    rid of these lines:

    Options:
    -P
    Inhibit generation of linemarkers in the output from the preprocessor.
    This might be useful when running the preprocessor on something that
    is not C code, and will be sent to a program which might be confused
    by the linemarkers. See Preprocessor Output.
    Gene, Aug 3, 2011
    #3
  4. Mateusz_madi

    mt Guest

    On Jul 31, 8:30 am, Ben Bacarisse <> wrote:
    > Mateusz_madi <> writes:
    > > Hi all, I have question about preprocessor. I fi have a program called
    > > binary_s.c and i put it only on preprocessor like:
    > > cc -E binary_s.c and i get strange output at the beginning of file
    > > like:

    >
    > > # 1 "binary_s.c"
    > > # 1 "<built-in>"
    > > # 1 "<command-line>"
    > > # 1 "binary_s.c"

    >
    > > What are those if I didn't included any libaries ?

    >
    > These are internal to the implementation (gcc, from the look of it).
    > The implementation can make the result of running only the preprocessor
    > almost anything it likes since the C standard does not mandate anything
    > but the overall effect of translating a program.  However, most
    > implementations try to make the output of the preprocessor valid C.  The
    > standard permits almost anything after a # and most implementations take
    > advantage of this to do keep track of information they might need later
    > on in the translation process.
    >
    > In this case, the lines record the position in the stream of tokens that
    > is being processed (mainly for error reporting).  For example, if you
    > had -include x.h on the command line, any tokens resulting from it would
    > have appeared between the 3rd and 4th lines of you example (together
    > with a further '#' line to note the new file being processed).  Any
    > errors in x.h can then be noted as coming from "x.h included from
    > command-line" or some such text.
    >
    > --
    > Ben.


    test post
    mt, Aug 5, 2011
    #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. Dan W.
    Replies:
    9
    Views:
    321
    Paul Mensonides
    Dec 4, 2003
  2. xuatla
    Replies:
    1
    Views:
    351
    Denis Remezov
    Jul 10, 2004
  3. Cronus
    Replies:
    1
    Views:
    633
    Paul Mensonides
    Jul 15, 2004
  4. ³á³á³á³á

    Preprocessor's question

    ³á³á³á³á, Sep 12, 2003, in forum: C Programming
    Replies:
    1
    Views:
    321
    Martin Ambuhl
    Sep 12, 2003
  5. Neil Zanella

    preprocessor question

    Neil Zanella, Nov 6, 2003, in forum: C Programming
    Replies:
    4
    Views:
    312
    Eric Sosman
    Nov 6, 2003
Loading...

Share This Page