Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextStream(stdout) use of undeclared identifier stdout
Forum Updated to NodeBB v4.3 + New Features

QTextStream(stdout) use of undeclared identifier stdout

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 4 Posters 2.9k Views 2 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.
  • B Bill52

    In a Console project I created a class and added :
    #include <QTextStream>

    When I add QTextStream(stdout) the IDE complains about 'use of undeclared identifier stdout' .

    I couldn't find any info about this on google or in the documentation.
    Anybody could point in the right direction?
    Thanks,
    Bill

    kshegunovK Offline
    kshegunovK Offline
    kshegunov
    Moderators
    wrote on last edited by
    #4

    @Bill52 said in QTextStream(stdout) use of undeclared identifier stdout:

    When I add QTextStream(stdout) the IDE complains about 'use of undeclared identifier stdout' .

    Your IDE is at fault. The error you observe comes from the code model your IDE uses. The problem is that it doesn't recognize QTextStream(stdout) as an anonymous (temporary) object, but instead parses this expression as a constructor-style cast. In any case giving a name to the object is going to fix it, e.g.:

    QTextStream out(stdout);
    out << "whatever";
    

    PS.
    MSVC 2015 (I think) had the same problem, but at compile time. So the above would be ill-formed if you were to use that compiler. You better stay off of such clever expressions, you may shoot yourself in the foot without even realizing.

    Read and abide by the Qt Code of Conduct

    B 1 Reply Last reply
    2
    • kshegunovK kshegunov

      @Bill52 said in QTextStream(stdout) use of undeclared identifier stdout:

      When I add QTextStream(stdout) the IDE complains about 'use of undeclared identifier stdout' .

      Your IDE is at fault. The error you observe comes from the code model your IDE uses. The problem is that it doesn't recognize QTextStream(stdout) as an anonymous (temporary) object, but instead parses this expression as a constructor-style cast. In any case giving a name to the object is going to fix it, e.g.:

      QTextStream out(stdout);
      out << "whatever";
      

      PS.
      MSVC 2015 (I think) had the same problem, but at compile time. So the above would be ill-formed if you were to use that compiler. You better stay off of such clever expressions, you may shoot yourself in the foot without even realizing.

      B Offline
      B Offline
      Bill52
      wrote on last edited by
      #5

      @kshegunov
      Thanks.
      Yes and no.
      Yes what you are saying but no, it doesn't fix it.

      I tried GCC7,x86/64 and GCC, x86/64. Both come with the Mint distro.
      Nothing fancy, just compiling for the local desktop.

      aha_1980A kshegunovK 2 Replies Last reply
      0
      • B Bill52

        @kshegunov
        Thanks.
        Yes and no.
        Yes what you are saying but no, it doesn't fix it.

        I tried GCC7,x86/64 and GCC, x86/64. Both come with the Mint distro.
        Nothing fancy, just compiling for the local desktop.

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #6

        @Bill52

        Which Creator version is that? And how did you install it?

        For me it works with Creator 4.9, Ubuntu 18.04 and the Clang Code Model enabled:
        0_1557854970671_bc3678e0-5415-4eee-8db0-24c70abcf974-image.png

        Usually such errors like yours happen when Clang cannot parse an include file completely (If it helps you: I have dozens of this in different projects).

        My code for testing:

        #include <QTextStream>
        
        int main(int argc, char *argv[])
        {
            QTextStream out(stdout);
        
            out << "Hello World" << endl;
        
            return 0;
        }
        

        Qt has to stay free or it will die.

        B 1 Reply Last reply
        0
        • aha_1980A aha_1980

          @Bill52

          Which Creator version is that? And how did you install it?

          For me it works with Creator 4.9, Ubuntu 18.04 and the Clang Code Model enabled:
          0_1557854970671_bc3678e0-5415-4eee-8db0-24c70abcf974-image.png

          Usually such errors like yours happen when Clang cannot parse an include file completely (If it helps you: I have dozens of this in different projects).

          My code for testing:

          #include <QTextStream>
          
          int main(int argc, char *argv[])
          {
              QTextStream out(stdout);
          
              out << "Hello World" << endl;
          
              return 0;
          }
          
          B Offline
          B Offline
          Bill52
          wrote on last edited by
          #7

          @aha_1980
          QT Creator 4.9.0
          Based on Qt 5.12.2 (GCC 5.3.1 20160406 (Red Hat 5.3.1-6), 64 bit)
          Built on Apr 12 2019 00:19:59
          From revision 7885bc899f

          Installed from the official QT website:
          https://www.qt.io/download-qt-installer ....
          OpenSource version. It happened all automatically.

          Now that you mention, I have a 'clang++:command not found' error when setting the compiler to this.

          aha_1980A 1 Reply Last reply
          0
          • B Bill52

            @aha_1980
            QT Creator 4.9.0
            Based on Qt 5.12.2 (GCC 5.3.1 20160406 (Red Hat 5.3.1-6), 64 bit)
            Built on Apr 12 2019 00:19:59
            From revision 7885bc899f

            Installed from the official QT website:
            https://www.qt.io/download-qt-installer ....
            OpenSource version. It happened all automatically.

            Now that you mention, I have a 'clang++:command not found' error when setting the compiler to this.

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #8

            @Bill52 said in QTextStream(stdout) use of undeclared identifier stdout:

            Now that you mention, I have a 'clang++:command not found' error when setting the compiler to this.

            Where do you have this error?

            Note that the Clang Code Model is integrated into Creator, and if you installed with the online installer it should be correctly set up...

            WhichUubuntu corresponds this Mint 19 to?

            Qt has to stay free or it will die.

            B 1 Reply Last reply
            0
            • aha_1980A aha_1980

              @Bill52 said in QTextStream(stdout) use of undeclared identifier stdout:

              Now that you mention, I have a 'clang++:command not found' error when setting the compiler to this.

              Where do you have this error?

              Note that the Clang Code Model is integrated into Creator, and if you installed with the online installer it should be correctly set up...

              WhichUubuntu corresponds this Mint 19 to?

              B Offline
              B Offline
              Bill52
              wrote on last edited by
              #9

              @aha_1980 said in QTextStream(stdout) use of undeclared identifier stdout:

              @Bill52 said in QTextStream(stdout) use of undeclared identifier stdout:

              Now that you mention, I have a 'clang++:command not found' error when setting the compiler to this.

              Where do you have this error?

              When compiling if the compiler is set to clang. (as it was when I first started up QTCreator. When nothing compiled, I changed it to GCC7.)

              Note that the Clang Code Model is integrated into Creator, and if you installed with the online installer it should be correctly set up...

              ... aaaammm ... unless I changed something .... and don't remember it ...
              But the clang compiler never worked. I didn't change it after install. To learn QT I was following the 'notepad' tutorial. When it didn't compile I changed it.

              WhichUubuntu corresponds this Mint 19 to?
              Ubuntu Bionic

              It's 2:33 AM at this end of the world. If I don't go to sleep I'll faint off the chair.
              Thanks for the help for all!

              Until tomorrow.

              aha_1980A 1 Reply Last reply
              0
              • B Bill52

                @kshegunov
                Thanks.
                Yes and no.
                Yes what you are saying but no, it doesn't fix it.

                I tried GCC7,x86/64 and GCC, x86/64. Both come with the Mint distro.
                Nothing fancy, just compiling for the local desktop.

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #10

                @Bill52 said in QTextStream(stdout) use of undeclared identifier stdout:

                Yes what you are saying but no, it doesn't fix it.

                Please provide a small screenshot so we know for sure what we are dealing with.

                Read and abide by the Qt Code of Conduct

                B 1 Reply Last reply
                0
                • B Bill52

                  @aha_1980 said in QTextStream(stdout) use of undeclared identifier stdout:

                  @Bill52 said in QTextStream(stdout) use of undeclared identifier stdout:

                  Now that you mention, I have a 'clang++:command not found' error when setting the compiler to this.

                  Where do you have this error?

                  When compiling if the compiler is set to clang. (as it was when I first started up QTCreator. When nothing compiled, I changed it to GCC7.)

                  Note that the Clang Code Model is integrated into Creator, and if you installed with the online installer it should be correctly set up...

                  ... aaaammm ... unless I changed something .... and don't remember it ...
                  But the clang compiler never worked. I didn't change it after install. To learn QT I was following the 'notepad' tutorial. When it didn't compile I changed it.

                  WhichUubuntu corresponds this Mint 19 to?
                  Ubuntu Bionic

                  It's 2:33 AM at this end of the world. If I don't go to sleep I'll faint off the chair.
                  Thanks for the help for all!

                  Until tomorrow.

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  @Bill52 said in QTextStream(stdout) use of undeclared identifier stdout:

                  ... aaaammm ... unless I changed something .... and don't remember it ...
                  But the clang compiler never worked. I didn't change it after install. To learn QT I was following the 'notepad' tutorial. When it didn't compile I changed it.

                  I'm using gcc for compiling, nevertheless QtCreator uses Clang in a library shipped together with the binary installer for its code model. This is (or say: should be) totally unrelated to other Clang compilers on your system.

                  To make it short: You can disable the Clang Code Model if you don't want to investigate this issue deeper: Help > About Plugins > Clang Code Model.

                  Regards

                  Qt has to stay free or it will die.

                  1 Reply Last reply
                  0
                  • kshegunovK kshegunov

                    @Bill52 said in QTextStream(stdout) use of undeclared identifier stdout:

                    Yes what you are saying but no, it doesn't fix it.

                    Please provide a small screenshot so we know for sure what we are dealing with.

                    B Offline
                    B Offline
                    Bill52
                    wrote on last edited by Bill52
                    #12

                    @kshegunov
                    Talking about screen capture, I just noticed an error that appeared under a small yellow triangle on the top of the IDE. It seems to be pointing to the source of the issue.

                    **Warning:** The code model could not parse an included file, which might lead to incorrect code completion and highlighting, for example.
                    os_defines.h:39:10: error: 'features.h' file not found
                    main.cpp:1:1: note: in file included from /home/user/PROGRAMMING/QT/HelloWorld/main.cpp:1:
                    main.cpp:1:10: note: in file included from /home/user/PROGRAMMING/QT/HelloWorld/main.cpp:1:
                    QCoreApplication:1:10: note: in file included from /home/user/Applications/Qt/5.12.3/gcc_64/include/QtCore/QCoreApplication:1:
                    qcoreapplication.h:43:10: note: in file included from /home/user/Applications/Qt/5.12.3/gcc_64/include/QtCore/qcoreapplication.h:43:
                    qglobal.h:45:12: note: in file included from /home/user/Applications/Qt/5.12.3/gcc_64/include/QtCore/qglobal.h:45:
                    type_traits:38:10: note: in file included from /usr/include/c++/7/type_traits:38:
                    c++config.h:533:10: note: in file included from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533:
                    

                    The 'features.h' is in /usr/include. The path seems to be missing, however:

                    user@Mint19:~$ cpp -v
                    Using built-in specs.
                    COLLECT_GCC=cpp
                    OFFLOAD_TARGET_NAMES=nvptx-none
                    OFFLOAD_TARGET_DEFAULT=1
                    Target: x86_64-linux-gnu
                    Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.4.0-1ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
                    Thread model: posix
                    gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04) 
                    COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=x86-64'
                     /usr/lib/gcc/x86_64-linux-gnu/7/cc1 -E -quiet -v -imultiarch x86_64-linux-gnu - -mtune=generic -march=x86-64 -fstack-protector-strong -Wformat -Wformat-security
                    ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
                    ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
                    #include "..." search starts here:
                    #include <...> search starts here:
                     /usr/lib/gcc/x86_64-linux-gnu/7/include
                     /usr/local/include
                     /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
                     /usr/include/x86_64-linux-gnu
                     /usr/include
                    End of search list.
                    

                    says that the path is known.
                    And I don't know how to go from here.

                    B 1 Reply Last reply
                    0
                    • B Bill52

                      @kshegunov
                      Talking about screen capture, I just noticed an error that appeared under a small yellow triangle on the top of the IDE. It seems to be pointing to the source of the issue.

                      **Warning:** The code model could not parse an included file, which might lead to incorrect code completion and highlighting, for example.
                      os_defines.h:39:10: error: 'features.h' file not found
                      main.cpp:1:1: note: in file included from /home/user/PROGRAMMING/QT/HelloWorld/main.cpp:1:
                      main.cpp:1:10: note: in file included from /home/user/PROGRAMMING/QT/HelloWorld/main.cpp:1:
                      QCoreApplication:1:10: note: in file included from /home/user/Applications/Qt/5.12.3/gcc_64/include/QtCore/QCoreApplication:1:
                      qcoreapplication.h:43:10: note: in file included from /home/user/Applications/Qt/5.12.3/gcc_64/include/QtCore/qcoreapplication.h:43:
                      qglobal.h:45:12: note: in file included from /home/user/Applications/Qt/5.12.3/gcc_64/include/QtCore/qglobal.h:45:
                      type_traits:38:10: note: in file included from /usr/include/c++/7/type_traits:38:
                      c++config.h:533:10: note: in file included from /usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:533:
                      

                      The 'features.h' is in /usr/include. The path seems to be missing, however:

                      user@Mint19:~$ cpp -v
                      Using built-in specs.
                      COLLECT_GCC=cpp
                      OFFLOAD_TARGET_NAMES=nvptx-none
                      OFFLOAD_TARGET_DEFAULT=1
                      Target: x86_64-linux-gnu
                      Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.4.0-1ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
                      Thread model: posix
                      gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04) 
                      COLLECT_GCC_OPTIONS='-E' '-v' '-mtune=generic' '-march=x86-64'
                       /usr/lib/gcc/x86_64-linux-gnu/7/cc1 -E -quiet -v -imultiarch x86_64-linux-gnu - -mtune=generic -march=x86-64 -fstack-protector-strong -Wformat -Wformat-security
                      ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
                      ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
                      #include "..." search starts here:
                      #include <...> search starts here:
                       /usr/lib/gcc/x86_64-linux-gnu/7/include
                       /usr/local/include
                       /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
                       /usr/include/x86_64-linux-gnu
                       /usr/include
                      End of search list.
                      

                      says that the path is known.
                      And I don't know how to go from here.

                      B Offline
                      B Offline
                      Bill52
                      wrote on last edited by
                      #13

                      @bill52 Just to close this topic in case anybody reads it.
                      The issue has never been solved. Reinstalling Qt didn't help.

                      Later KDE was installed then Qt 5.13.1 via the offline installer.
                      After some teething issues it now works. (since yesterday)

                      As a final thought: the offline/online installers failed when i run them from the GUI (dolphin).
                      The offline installer succeeded when run it from the terminal.

                      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