程序在开始运行前被卡住

编程入门 行业动态 更新时间:2024-10-23 03:13:28
本文介绍了程序在开始运行前被卡住的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好, 我的C ++程序(控制台应用程序)在进入main()函数之前就被卡住了(控制台已打开,什么也没发生). (我检查了VS6和VS2010,并遇到了相同的问题) 在更改了我使用的一个库之后,这个问题开始了. 这个问题的原因可能是什么(库,相关的dll?) 如何检查程序卡在哪里?有没有推荐的工具来检查它? 谢谢, Dotan Knaan

Hello, My C++ program (console application)is stuck even before it get to the main() function (the console is open, and nothing happens). (I check with VS6 and VS2010 and got the same problem) This problem started after I changed one of the libraries that I use. What can be the reason for this problem (the libraries, related dlls?) How can I check where the program is stuck? Are there any recommended tools to check it? Thanks, Dotan Knaan

推荐答案

使用调试器并获取所有线程的堆栈跟踪. Use a debugger and get stack traces for all the threads.

它很可能是全局变量(某类)初始化. 在代码进入main()函数之前,所有全局变量都作为CRT启动的一部分进行初始化(并在main()函数返回后清除). 开始调试,让它运行几秒钟,然后在调试器上按暂停键.调试器将中断,并向您显示当前的位置.猜测可能是无限循环,还是等待Mutex或Semaphore之类的东西. It will most likely be a global variable (of a class) initialising. All global variables are initialised as part of the CRT startup, before the code enters the main() function (and cleaned up after the main() function returns) Start debugging and let it run for a few seconds, then hit pause on the debugger. The debugger will break and show you where it is currently up to. At a guess it will be either an infinite loop or waiting on something like a Mutex or Semaphore

在开发环境中运行时,您只需暂停程序并在堆栈窗口中查看(按住Ctrl-Alt-C组合键的位置).这将为您提供有关文件使用哪种方法以及问题出在哪里的信息(可能). 祝你好运! When you run in the development environment you can simply pause the program and see in the stack window (Ctrl-Alt-C) where it is running at the time of pausing. This would give you some info on which method with the file and that be where the problem is (probably). Good luck!

更多推荐

程序在开始运行前被卡住

本文发布于:2023-11-23 18:35:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1622476.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!