Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Preprocessor question (http://www.velocityreviews.com/forums/t752228-preprocessor-question.html)

Mateusz_madi 07-31-2011 11:16 AM

Preprocessor question
 
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

Ben Bacarisse 07-31-2011 12:30 PM

Re: Preprocessor question
 
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 08-02-2011 11:06 PM

Re: Preprocessor question
 
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.



mt 08-05-2011 01:39 AM

Re: Preprocessor question
 
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


All times are GMT. The time now is 01:04 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57