![]() |
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 |
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. |
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. |
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.