我在调试一个给定的C++代码时,使用F11键(步进模式)以了解代码中函数被调用的精确顺序,并且我意识到在某些函数内部,除非我在函数定义中的某行设置断点,否则它永远不会进入这些函数。
我的意思是,如果我从主方法调用一个在另一个.cpp文件中定义的函数,我希望F11调试模式逐步进入函数,以便分析变量的更改。大多数情况下是可以的,但在某些情况下,它只是执行函数而不进入它,并跳转到主方法中的下一行。
为什么会发生这种情况? 示例: 这是F11永远不会进入的函数:
我的意思是,如果我从主方法调用一个在另一个.cpp文件中定义的函数,我希望F11调试模式逐步进入函数,以便分析变量的更改。大多数情况下是可以的,但在某些情况下,它只是执行函数而不进入它,并跳转到主方法中的下一行。
为什么会发生这种情况? 示例: 这是F11永远不会进入的函数:
void VirtualCamera::display (void) {
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Clear the background of the window
glClear(GL_COLOR_BUFFER_BIT); //Clear the colour buffer (more buffers later on)
glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations
glTranslatef(0.0f, 0.0f, -5.0f);
renderPrimitive(); // Render the primitive
glFlush(); // Flush the OpenGL buffers to the window
}
这是主方法,F11会一步一步执行:
void VirtualCamera::CameraMain(int argc, char **argv){
glutInit(&argc, argv); // Initialize GLUT
glutInitDisplayMode (GLUT_SINGLE);
glutInitWindowSize (500, 500); // Set the width and height of the window
glutInitWindowPosition (100, 100); // Set the position of the window
glutCreateWindow ("OpenGL Window"); // Set the title for the window
glutDisplayFunc(display); // Tell GLUT to use the method "display" for rendering
glutReshapeFunc(reshape);
glutMainLoop(); // Enter GLUT's main loop
}
glutMainLoop()
这一行时,也会进入display函数,但只有在我在display(void)
内设置断点时才会进入。 - Jav_Rock