Which code I must return?



  • Hi all.

    I have the simple program.
    But, after end of program I have message "During startup program exited with code 0x0".

    The program code is following:
    main.cpp
    @#include <iostream>

    int main(int argc, char *argv[])
    {
    std::cout << "Hello!";
    return 0;
    }@
    test2.pro
    @QT += core
    QT -= gui
    TARGET = test2
    CONFIG += console
    CONFIG -= app_bundle
    TEMPLATE = app
    SOURCES += main.cpp@
    Which code I need returning that there is no error?
    Thanks.


    Best regards,
    Galiego710


  • Moderators

    Welcome to this forum.

    In principle you may return any code you like. However, 0 is typically used to indicate that there has been no error encountered. The message you are seeing is a standard information message telling you the return code. It is not an error message and everything is fine.



  • Thanks, koahnig

    But it looks how an error message.
    Are there any way to avoid this message?

    http://img.flashtux.org/img132df0830e70xb81e77a9.png


  • Moderators

    You are right this looks like an error message. When I read your return code message, I thought it is the standard message you see for some console programs.

    Which operation system are using?



  • Operation system is Windows7 (Processor amd64)
    Information from "About Qt Creator"
    Qt Creator 2.3.0 (based on Qt 4.7.4)
    build Aug 25 2011 in 15:26:28
    revision: 0c9dc89d0b


  • Moderators

    That is the output see under Linux built with qt creator

    @Starting ./helloWorld-build-desktop/helloWorld...
    Hello World !
    ./helloWorld-build-desktop/helloWorld exited with code 0 @

    I have tried it also under windows 7 with msvc2005 for a console application you will see only
    @
    Hello World !
    @

    I do not have qt creator installed on windows for cross check.

    The phrase "During start-up " puzzles me a little. I did not see immendiately, but together with the screen shot you have posted, it looks really strange.

    When you change the return to a different value, does it output this new value?


  • Moderators

    The message just states the error code that your code returned. There was no error (otherwise it would say so in the message).

    If we would not give that message in Qt Creator then you had little chance to debug error cases where your application just exists with some error code. This message will not show up when running this application outside Qt Creator.



    • to koahnig:

    bq. When you change the return to a different value, does it output this new value?

    Yes, when I return a diffrent values, it show me respective values.

    • to Tobias Hunger:

    bq. There was no error (otherwise it would say so in the message).

    Oh, okay... Simply, I been puzzled the image of the red circle with the white cross.

    Problem resolved, thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.