Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Standard input stream redirection on debug
Forum Updated to NodeBB v4.3 + New Features

Standard input stream redirection on debug

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 3.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PunyOne
    wrote on last edited by
    #1

    Hi,

    I am trying to port my project to QT and I need to use input stream redirection ( "<my_file_name") or run. I use the arguments field in project settings to set it up, but the problem is that whereas in the realease build it works, in the debug one, it actually takes "<my_file_name" as an argument and feeds it to the application.

    More explicitly, following code:
    @#include <iostream>
    #include <string>

    using namespace std;

    int main(int argc, char **argv)
    {
    for (int i = 0; i < argc; i++)
    cout << string (argv[i]) << std::endl;
    }@

    run with an argument "<some_existing_file.txt" does nothing on Release build and prints "<some_existing_file.txt" on Debug build.

    I use Windows (tested on two different Win-based platforms), Qt 4.8.1 with MVSC2010 compiler and CDB debugger.

    Any idea how to fix it so it? Thank you.

    Adam

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DigitalPioneer
      wrote on last edited by
      #2

      Have you tried putting a space between < and filename? I don't know how picky the Windows shell is about such things. Also, you're not putting quotes around <filename in Qt Creator, right? It works for me, but I'm on Linux.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        PunyOne
        wrote on last edited by
        #3

        Unfortunatelly, that run parameter (which is shared among build configurations) works for Release, so it's form is OK.

        However, thanks for that Linux remark, now it seems more likely that the CDB causes the problem.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DigitalPioneer
          wrote on last edited by
          #4

          Ahhh, yes. That's probably it; the CDB command probably looks like
          @cdb "yourprogram.exe <inputfile"@
          Or the like, and CDB doesn't evaluate <inputfile as a redirection, but simply passes it as a parameter instead. I don't know how you can fix that, short of making the input an actual first class parameter to the program. Maybe read a file if it's provided, fall back to cin if not?

          1 Reply Last reply
          0
          • P Offline
            P Offline
            PunyOne
            wrote on last edited by
            #5

            You are right, that really seems like a thing that could be causing the trouble.

            There are of course many ways how to solve this problem, I have however hoped that I would not be required to change the code itself. I have only a little experience with usage of a command-line debugger - would anybody know some command that would tell the CDB to handle the argument as a stream redirection? Thanks.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved