Qt Creator - Code is running but I get an error message from the IDE

c, c++, ide, qt, qt-creator

Solution

I have met same problem. Tips and advices on forums are rather clueless, so I investigated problem myself and I have found that it's a bug in QtCreator.

There is dirty little program called `qtcreator_process_stub`. Whenever you run your program within IDE, IDE first runs `qtcreator_process_stub` and passes your program name as parameter (among some other parameters). `qtcreator_process_stub` then starts your program as separate process and prints its PID (and on windows also thread id). Information is printed to the pipe and then it is read by `ConsoleProcess::readStubOutput()`, which is part of `Utils.dll` library used by QtCreator.

The problem occurs when "inferior" process (your application) finishes execution before whole communication has been processed. `ConsoleProcess::readStubOutput()` attempts to use `OpenProcess()` on non-existing process with closed handle. `OpenProcess()` fails hence error "Cannot obtain a handle to the inferior: The parameter is incorrect.". Whole error is not handled very gently (Uhm, and now what?)... :-/

Solution: When you add some user input action, pause, sleep, delay or just some loops, so that execution of your application is a bit longer error vanishes. There is enough time for `ConsoleProcess::readStubOutput()` to execute `OpenProcess()`, before your application quits. So as a workaroud I suggest to do that until the bug is fixed.

Problem

As soon as I run my code (note that I'm using C only, no QT and no C++) I get the following message from the application output inside the IDE: Cannot obtain a handle to the inferior: The parameter is incorrect. When I delete the makefiles and debug/release folders it's running but after some time I still get the error. It's not that much of a problem though, the code runs and everything is fine but this error pops up and it's quite annoying. The content of the .pro file is: ``` TEMPLATE = app CONFIG += console CONFIG -= app_bundle CONFIG -= qt QMAKE_CC = gcc -std=c99 SOURCES += main.c ``` Thanks in advance! edit: I have added C++ tag, because this error occurs also for C++ console application as in my case.

Original source