gpt4 book ai didi

c++ - 在 C++ 中使用嵌套注释快速(取消)激活代码块的危险

转载 作者:太空狗 更新时间:2023-10-29 19:46:50 25 4
gpt4 key购买 nike

我目前正在使用嵌套注释在测试期间快速激活/停用代码,我这样做的方式是这样的:

//* First Case, Activated
DoSomething();
/**/

/* Second Case, De-Activated
DoSomethingElse();
/**/

我可以通过简单地添加或删除“/”来激活、停用代码块。

编译器警告我这一点,因为嵌套注释不好,但实际上,使用这些注释是否危险?

最佳答案

人们通常是这样做的:

#if 0
//...
#endif

#define TESTWITH

#ifdef TESTWITH
//..
#endif

关于c++ - 在 C++ 中使用嵌套注释快速(取消)激活代码块的危险,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6652637/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com