这可能是一个风格的问题,但我们的开发团队中存在一些分歧,我想知道是否有其他人对此有任何 idea ...
基本上,我们有一些调试打印语句,在正常开发过程中关闭这些语句.就我个人而言,我更喜欢做以下事情:
//---- SomeSourceFile.cpp ----
#define DEBUG_ENABLED (0)
...
SomeFunction()
{
int someVariable = 5;
#if(DEBUG_ENABLED)
printf("Debugging: someVariable == %d", someVariable);
#endif
}
不过,团队中的一些人更喜欢以下内容:
// #define DEBUG_ENABLED
...
SomeFunction()
{
int someVariable = 5;
#ifdef DEBUG_ENABLED
printf("Debugging: someVariable == %d", someVariable);
#endif
}
...你觉得哪种方法更好?为什么?我的感觉是,第一个更安全,因为总是有定义的东西,它不会 destruct 其他地方的定义.