Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > commenting out 'cout' using preprocessor macro

Reply
Thread Tools

commenting out 'cout' using preprocessor macro

 
 
Samuele Armondi
Guest
Posts: n/a
 
      08-08-2003

"Samuele Armondi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "qazmlp" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > I hope comp.lang.c will not find the following question as a
> > complete off-topic.

[snip...]
> But you would need to be 100% sure that the code in question does not use
> the << _anywhere_. Hope this helps anyway!
> S. Armondi
>

Sorry, ignore all the \ in the declaration of the MyStream class. They are
not needed.
S. Armondi


 
Reply With Quote
 
 
 
 
Bill Cunningham
Guest
Posts: n/a
 
      08-09-2003


> after the phase 3 of the translation in both languages.
>
> Victor


What exactly is phase 3 translation? Into assembly or RTL perhaps?

Bill





-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
 
Reply With Quote
 
 
 
 
Jeff
Guest
Posts: n/a
 
      08-09-2003

"Victor Bazarov" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> "Jeff" <(E-Mail Removed)> wrote...
> >
> > "qazmlp" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) om...
> > > I hope comp.lang.c will not find the following question as a
> > > complete off-topic.
> > >
> > > I would like to remove ie.comment out the 'cout' statements during
> > > compilation(actually preprocessing) time.
> > >
> > >
> > > The statements like this:
> > > cout<<"something\n" ;
> > > should be made as
> > > // cout<<"something\n" ;
> > >
> > >

> >
> > Sorry, it is off-topic here. cout is a part of C++, not C.

>
> Sorry, Jeff, statements explaining what is off-topic in
> comp.lang.c are off-topic in comp.lang.c++. And give "qazmlp"
> a break, he expressed his hope, didn't he?
>


Sorry, Victor, statements explaining the other is off-topic here is also off-topic.

Unfortunately, you are off-topic now.

(Just to remind you, we have the right to protect our c.l.c group from off-topic by kindly notifying
the OP. It is usual on Usenet and I am not the first one. If you insist that the OP is not off-topic
here, you can give your opinion)

> Victor
>
>


--
Jeff


 
Reply With Quote
 
Jack Klein
Guest
Posts: n/a
 
      08-09-2003
On Fri, 8 Aug 2003 23:57:54 -0400, "Bill Cunningham" <(E-Mail Removed)>
wrote in comp.lang.c:

>
>
> > after the phase 3 of the translation in both languages.
> >
> > Victor

>
> What exactly is phase 3 translation? Into assembly or RTL perhaps?
>
> Bill


The original ANSI/ISO C language standard (1989/1990) provided a
high-level definition of the translation process that an
implementation performs in producing executable code from a source
file. These have persisted to the present in later versions of the C
standard and have been incorporated into the C++ standard.

Like everything else in C and C++, the "as-if" rule applies, meaning
that a compiler does not have use separate passes to perform all of
these operations. It can do them in parallel as long as the proper
ordering is used.

They are too long to quote here in full, but the two that are relevant
to this question are that in phase 3, "Each comment is replaced by one
space character", and in phase 4, "Preprocessing directives are
executed and macro invocations are expanded".

So there is no way of including a comment in the expansion of a macro.
The early lexical analysis step removes comments before the
preprocessor expands macros.

An overview of the 8 phases of translation:

1 through 6 deals with parsing and preprocessor issues. At the end of
phase 6 the program is a series of tokens, without white space, with
all comments removed and macros expanded.

Phase 7 actually analyses and translates the program into some sort of
output format, generally referred to as an object file.

Phase 8 is after compilation, usually performed by a separate tool
called a linker. It resolves references between different source
files and to library modules and generally produces the final
executable output file.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      08-09-2003
"Jeff" <(E-Mail Removed)> wrote...
> [...]
> Sorry, Victor, statements explaining the other is off-topic here is also

off-topic.

REALLY?

> Unfortunately, you are off-topic now.
>
> (Just to remind you, we have the right to protect our c.l.c group from

off-topic by kindly notifying
> the OP. It is usual on Usenet and I am not the first one. If you insist

that the OP is not off-topic
> here, you can give your opinion)


I already have. If you need it again, go to my first reply to you
and re-read it.


 
Reply With Quote
 
John L Fjellstad
Guest
Posts: n/a
 
      08-14-2003
qazmlp wrote:

> I would like to remove ie.comment out the 'cout' statements during
> compilation(actually preprocessing) time.


I saw this in a computer mag once (either C++ journal or something like
that):

#ifdef DEBUG
#define SLASH(s) /##s
#define COMMENT SLASH(/)
#else
#define COMMENT std::cout
#endif

Unfortunately, I don't know how portable this is (someone could probably
explain why it won't work). I could get it working on VisualC++ v6, but
had problems with GCC v2.9x. Think it worked in aCC (the HPUX compiler)

--
John L. Fjellstad
 
Reply With Quote
 
Martin Dickopp
Guest
Posts: n/a
 
      08-14-2003
John L Fjellstad <(E-Mail Removed)> writes:

> I saw this in a computer mag once (either C++ journal or something like
> that):
>
> #ifdef DEBUG
> #define SLASH(s) /##s
> #define COMMENT SLASH(/)
> #else
> #define COMMENT std::cout
> #endif
>
> Unfortunately, I don't know how portable this is (someone could probably
> explain why it won't work).


Comments are removed (or rather replaced by a whitespace character) in
translation phase 3, while preprocessing directives are executed and macros
are expanded in translation phase 4. Therefore, `//' is not a meaningful
preprocessing token at the point when `COMMENT' is expanded.

Martin
 
Reply With Quote
 
John L Fjellstad
Guest
Posts: n/a
 
      08-16-2003
Martin Dickopp wrote:

> Comments are removed (or rather replaced by a whitespace character) in
> translation phase 3, while preprocessing directives are executed and
> macros are expanded in translation phase 4. Therefore, `//' is not a
> meaningful preprocessing token at the point when `COMMENT' is expanded.


Do you know if this is in the C++ standard, or if it is left to the
implementation?

--
John L. Fjellstad
 
Reply With Quote
 
Martin Dickopp
Guest
Posts: n/a
 
      08-16-2003
John L Fjellstad <(E-Mail Removed)> writes:

> Martin Dickopp wrote:
>
> > Comments are removed (or rather replaced by a whitespace character) in
> > translation phase 3, while preprocessing directives are executed and
> > macros are expanded in translation phase 4. Therefore, `//' is not a
> > meaningful preprocessing token at the point when `COMMENT' is expanded.

>
> Do you know if this is in the C++ standard, or if it is left to the
> implementation?


This behavior is required by the C++ standard (section 2.1#1) as well as the
C standard (section 5.1.1.2#1).

Martin


(Followup-To: comp.lang.c++ ignored, since the discussion seems meaningful
to both C and C++.)
 
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
java commenting out of code patrick Java 4 01-11-2006 03:05 PM
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
Commenting out VB code =?Utf-8?B?U2FuZHk=?= ASP .Net 5 02-03-2005 05:51 PM
preprocessor, token concatenation, no valid preprocessor token Cronus C++ 1 07-14-2004 11:10 PM
commenting out 'cout' using preprocessor macro qazmlp C++ 18 08-16-2003 12:59 PM



Advertisments