1

What could be the cause for a program to crash/exit before entering the main() function?

I am working on a project that was running normally. I added some code that uses boost threads, I updated the makefiles (CMakeLists.txt), and everything compiles and links without issues.

When I launch the executable, all I get is the prompt.

To check if the programs starts doing something, I add a cerr << "TEST" << endl as the first instruction in main(), and nothing is printed.

Of course when I try to print that string no threads are created, yet.

Putting a break point at the beginning of main() is useless.

System:
Windows 7, MinGW, GCC, cmake

4

2 回答 2

5

问题可能出在某些全局类变量的构造函数中。他们将在之前被调用main

于 2013-07-20T17:39:02.863 回答
0

另一种可能的情况是输出已经被缓存,进入main后进程崩溃,请在输出行后面添加flush输出,或者你可以重新打印1000次以确保它没有被缓存。

在这种情况下,简单的方法是在调试器中运行它,它将缓存错误。

于 2013-07-20T18:40:55.413 回答