今天在调试cocos2d-x3.0的源码时,发现VS2012的一个调试信息现实错误的bug,代码如下:
static int sceneIdx = -1;
Layer* nextActionManagerAction()
{
//CCLOG("%d",sceneIdx);
sceneIdx++;
//CCLOG("%d",sceneIdx);
sceneIdx = sceneIdx % MAX_LAYER;
//CCLOG("%d",sceneIdx);
auto layer = createActionManagerLayer(sceneIdx);
layer->autorelease();
return layer;
}
上述代码中,sceneIdx的值在调试时一直显示为-1。刚开始我很纳闷,以为是static关键字导致的。后来继续调试发现,
sceneIdx++;
sceneIdx = sceneIdx % MAX_LAYER;
这两行代码执行过后,编译器调试信息中的sceneIdx 的值显示仍然是-1。于是乎我就将运行时的值打印到输出里,结果发现,这段代码
//CCLOG("%d",sceneIdx);
scene