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. Problems with <bits/stdc++.h>
QtWS25 Last Chance

Problems with <bits/stdc++.h>

Scheduled Pinned Locked Moved Unsolved General and Desktop
include
9 Posts 5 Posters 2.9k Views
  • 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.
  • A Offline
    A Offline
    Aditya Gupta
    wrote on last edited by
    #1

    I have just started learning the Qt framework, and have got the basics of what I want running. Now, I would like to reuse code from 'normal' c++ in a new header file. This code utilized the standard library so I included <bits/stdc++.h>. When I try to include this in my Qt code however, I get an error when attempting to build my project:

    no matching function for call to 'std::filesystem::__cx11::path::path(const string_type&)'

    I seem to have kind of fixed the problem by manually copying and pasting the include of bits/stdc++.h, but clearly this solution is not ideal - does anyone know why this include is not working?

    (Windows 10)

    SGaistS 1 Reply Last reply
    0
    • H Offline
      H Offline
      hbatalha
      wrote on last edited by
      #2

      What mingw version are you using in Qt?

      Check your kits in your project. You may have to manually add the mingw compiler that enables you to use the std::filesystem for example.

      Also, Qt has its own "everything" standard C++ has. Check the Qt equivalent of std::filesystem.

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Aditya Gupta
        wrote on last edited by
        #3

        I think I am using 'mingw810_64'; at least, that is what is showing up in the error. How would I add the correct compiler?

        H 1 Reply Last reply
        0
        • A Aditya Gupta

          I think I am using 'mingw810_64'; at least, that is what is showing up in the error. How would I add the correct compiler?

          H Offline
          H Offline
          hbatalha
          wrote on last edited by
          #4

          @Aditya-Gupta mingw810_64 doesn't have std::filesystem.

          How would I add the correct compiler?

          Go to Tool > Options > Kits > Compilers Tab, there's an add button in the right top corner.

          1 Reply Last reply
          1
          • A Aditya Gupta

            I have just started learning the Qt framework, and have got the basics of what I want running. Now, I would like to reuse code from 'normal' c++ in a new header file. This code utilized the standard library so I included <bits/stdc++.h>. When I try to include this in my Qt code however, I get an error when attempting to build my project:

            no matching function for call to 'std::filesystem::__cx11::path::path(const string_type&)'

            I seem to have kind of fixed the problem by manually copying and pasting the include of bits/stdc++.h, but clearly this solution is not ideal - does anyone know why this include is not working?

            (Windows 10)

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Aditya-Gupta hi and welcome to devnet,

            What exactly are you using from the standard library ?
            Usually you don't directly include the bits headers but the one matching the parts you want to use.

            @hbatalha said in Problems with <bits/stdc++.h>:

            Also, Qt has its own "everything" standard C++ has. Check the Qt equivalent of std::filesystem.

            That's wrong, Qt does not have everything the std has although it has helped shape some elements from the standard. In any case, there's QFile and QDir that where there long before the std::filesystem library.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            4
            • A Offline
              A Offline
              Aditya Gupta
              wrote on last edited by
              #6

              I'm trying to build a GUI for a previous project I had built with standard c++, and am principally using <algorithm>, <vector>, <map> and maybe a few others. More than anything I'd like to know how to include bits/stdc++.h for the future, but for the moment I am just including the files I need separately.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                That's the correct way to do it. Include only what you use.

                Also, AFAIK, that bits header is GCC specific so you'll end up with other issues of portability.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                2
                • Chris KawaC Offline
                  Chris KawaC Offline
                  Chris Kawa
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  As @SGaist mentioned this header is a non-standard addition of GCC/MinGW and it basically includes everything from std. Can be useful in large projects to optimize compilation times when used in a precompiled header, but otherwise you should avoid it and include only what you actually use from the standard, portable headers.

                  The specific problem here is that one of the headers included here is <filesystem> which has a bug you see in this version of MinGW. Your options are to upgrade to newer MinGW (this issue is supposedly fixed in version 9) or just don't use that header, which I would suggest.

                  1 Reply Last reply
                  2
                  • Kent-DorfmanK Offline
                    Kent-DorfmanK Offline
                    Kent-Dorfman
                    wrote on last edited by
                    #9

                    as the others mentioned...you don't include bits/{anything}. that directory is for platform specific internal headers that are only to be called by the generic platform independent abstractions. Furthermore, convention is that the parts of the stdlib that have been made available to c++ don't end with .h they are c{headername}, not {headername}.h ... iow, no extension at all in the filename.

                    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