[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c

Preprocessor question

Mateusz_madi

7/31/2011 11:17:00 AM

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
3 Answers

Ben Bacarisse

7/31/2011 12:30:00 PM

0

Mateusz_madi <madi.czadi@gmail.com> 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.

Gene

8/2/2011 11:06:00 PM

0

On Jul 31, 7:16 am, Mateusz_madi <madi.cz...@gmail.com> 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.


mahdert

8/5/2011 1:40:00 AM

0

On Jul 31, 8:30 am, Ben Bacarisse <ben.use...@bsb.me.uk> wrote:
> Mateusz_madi <madi.cz...@gmail.com> 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