Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > C preprocessor

Reply
Thread Tools

C preprocessor

 
 
mohdalibaig@gmail.com
Guest
Posts: n/a
 
      03-30-2007
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.

 
Reply With Quote
 
 
 
 
santosh
Guest
Posts: n/a
 
      03-30-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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.

 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      03-30-2007

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>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


 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      03-30-2007
Mike Wahler said:

>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
>>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.
 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      03-30-2007
Richard Heathfield wrote On 03/30/07 11:42,:
> Mike Wahler said:
>
>
>><(E-Mail Removed)> wrote in message
>>news:(E-Mail Removed) roups.com...
>>
>>>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?

--
(E-Mail Removed)
 
Reply With Quote
 
Mike Wahler
Guest
Posts: n/a
 
      03-30-2007

"Richard Heathfield" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Mike Wahler said:
>
>>
>> <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed) ups.com...
>>>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


 
Reply With Quote
 
Richard Heathfield
Guest
Posts: n/a
 
      03-30-2007
Mike Wahler said:

>
> "Richard Heathfield" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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.
 
Reply With Quote
 
=?utf-8?B?SGFyYWxkIHZhbiBExLNr?=
Guest
Posts: n/a
 
      03-30-2007
Eric Sosman wrote:
> Richard Heathfield wrote On 03/30/07 11:42,:
> > Mike Wahler said:
> >
> >
> >><(E-Mail Removed)> wrote in message
> >>news:(E-Mail Removed) roups.com...
> >>
> >>>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;
}

 
Reply With Quote
 
Eric Sosman
Guest
Posts: n/a
 
      03-30-2007
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:
>>>
>>>
>>>
>>>><(E-Mail Removed)> wrote in message
>>>>news:(E-Mail Removed) egroups.com...
>>>>
>>>>
>>>>>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....fee5801b14df99

... 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.

--
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiler error occurred when try to use a flexible template expression in preprocessor definesCompiler error occurred when try to use a flexible template expression in preprocessor defines snnn C++ 6 03-14-2005 04:09 PM
C# Preprocessor =?Utf-8?B?SSBhbSBTYW0=?= ASP .Net 2 03-13-2005 02:47 PM
preprocessor, token concatenation, no valid preprocessor token Cronus C++ 1 07-14-2004 11:10 PM
VHDL Preprocessor The Weiss Family VHDL 2 07-14-2004 05:51 AM
Preprocessor conditional compilation variable not being saved Chris P ASP .Net 0 10-28-2003 08:48 PM



Advertisments