PDA

View Full Version : Exit Code 3



RSX
10th March 2011, 23:39
Not sure if it's right board but it concerns Qt so... I got this code:


// main.h

#include "ui.h"

class Main {
public:
Main()
{
}

void init() {
ui.show();
}
private:
UI ui;
};



// main. cpp

#include "main.h"
#include <QtGui/QApplication>

Main g_main;

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

g_main.init();

return a.exec();
}


And the problem is that creating g_main as a global variable gives me this:
URL removed

With some console errors:


Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
Exited with code 3


When I put Main g_main as a local variable into main() function then everything works fine. Moreover, in another project (without Qt) I have no such problem.

I'm using Qt 4.7.0 with MingW.

wysota
10th March 2011, 23:53
What is UI? It looks like a widget so it can't be global because you need a QApplication instance to be able to instantiate widgets. You should even get a warning about this at run time.

RSX
11th March 2011, 00:17
UI is my main window (inherits QWidget) and the only warning I get is "Invalid parameter passed to C runtime function.".

Anyway, the problem disappeared after declaring ui on heap and initializing it with the new keyword.

wysota
11th March 2011, 00:26
UI is my main window (inherits QWidget) and the only warning I get is "Invalid parameter passed to C runtime function.".
This is an error not a warning. The warning goes to the console that you can't see without a development environment.


Anyway, the problem disappeared after declaring ui on heap and initializing it with the new keyword.
...after QApplication is initalized.

RSX
11th March 2011, 00:44
This is an error not a warning. The warning goes to the console that you can't see without a development environment.


I'm using Qt IDE so I should receive it there anyway.



...after QApplication is initalized.


Yes, in the init() function which is ... exactly what you said.