Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

_fileno returns different value in Visual Studio and QtCreator



  • This is the value in VS: vs
    This is the value in QtCreator:qt

    Why would I be getting two different values for _fileno(stdout) in two different IDEs using same compiler and same code?
    I use same compiler in both, msvc.

    tl;dr my _fileno(stdout) returns -2 in VS and 1 in QtCreator.



  • @InsaneZulol
    Presumably you do not get this difference if you run the app on each system outside of Creator?

    Are you running in Debug mode? Maybe to do with how they redirect to capture into the IDE console? Again, do you get the same result if you let each IDE run it not in Debug mode?

    EDIT I did not see you said it is returning -2. That seems odd.


  • Moderators

    According to the documentation -2 is the value returned when there's no output stream associated with given stream handle.
    I'm guessing you're compiling/running your app as windowed in VS (/SUBSYSTEM:WINDOWS) and as a console application in Qt Creator so there's a valid output stream there.



  • @Chris-Kawa I think I understand. Even tho my Qt app is not a console app nor do I start it from terminal - "Application Output" window is valid console output and thats why it doesn't result in -2 in QtCreator. Thank you.


Log in to reply