应该使用哪个预处理器定义来指定代码的调试部分?
使用#ifdef _DEBUG或者#ifndef NDEBUG是否有更好的方法来做到这一点,例如#define MY_DEBUG?
我认为_DEBUG是Visual Studio特有的,是NDEBUG标准吗?
为什么发布版本memset比visual studio 2012中的调试版本慢?在视觉sutido 2010中,也是这样的结果.我的电脑:
英特尔酷睿i7-3770 3.40GHz 8G内存操作系统:windows 7 sp1 64bit
这是我的测试代码:
#include <boost/progress.hpp>
int main()
{
const int Size = 1000*1024*1024;
char* Data = (char*)malloc(Size);
#ifdef _DEBUG
printf_s("debug\n");
#else
printf_s("release\n");
#endif
boost::progress_timer timer;
memset(Data, 0, Size);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
release
0.27 s
debug
0.06 s
Run Code Online (Sandbox Code Playgroud)
编辑:
if i change code to this, it will get the same result:
#include <boost/progress.hpp>
int main()
{
const int Size = 1000*1024*1024;
char* Data = (char*)malloc(Size);
memset(Data, 1, Size);
#ifdef _DEBUG
printf_s("debug\n");
#else …Run Code Online (Sandbox Code Playgroud)