本文介绍了使用预处理器宏评论'cout'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望comp.lang.c不会发现以下问题作为

完全偏离主题。


我想删除ie。在

汇编(实际预处理)时间内注释掉''cout''语句。

这样的陈述:

cout<< " something\\\
" ;

应该是

// cout<<" something\\\
" ;

我尝试了以下内容。但是,它似乎没有工作。

// -------- START

#ifdef DEBUG

#define COUT std :: cout

#else

#define COUT \ / \ /

#endif


int main()

{

COUT<<" HELLO \ n"<< std :: endl;

}


// --------结束

如果你能解决上述问题,请建议一个方法采取

照顾

评论超过1行的cout陈述。

例如:


12 COUT<<" HELLO \ n"

13<<" WORLD \ n" ;

解决方案




这绝对是一个c ++问题,但同样的概念在c中起作用。

预处理器直接复制你所拥有的内容一个定义,所以为什么

不仅仅有

#define COUT //

Allan





对不起,这是偏离主题的。 cout是C ++的一部分,而不是C.


[snip]


-

Jeff



对不起,这里不是主题。 cout是C ++的一部分,而不是C。




对不起,杰夫,在

comp.lang中解释什么是偏离主题的陈述。 c在comp.lang.c ++中是偏离主题的。然后给qazmlp

a休息,他表示希望,不是吗?


Victor


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" ;
I tried for the following. But, It doesn''t seem to be working.
//--------START
#ifdef DEBUG
#define COUT std::cout
#else
#define COUT \/\/
#endif

int main()
{
COUT<<"HELLO\n"<<std::endl ;
}

//--------END
If you can solve the above problem, please suggest a way for taking
care of
commenting out the ''cout'' statements that spans in more than 1 line.
eg:

12 COUT<<"HELLO\n"
13 <<"WORLD\n" ;

解决方案



This is most definately a c++ question, but the same concept works in c.
The preprocessor directly copies across what you have in a define, so why
not just have
#define COUT //
Allan




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

[snip]

--
Jeff




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?

Victor


这篇关于使用预处理器宏评论'cout'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 07:34