Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Problems with <bits/stdc++.h>

    General and Desktop
    include
    5
    9
    1070
    Loading More Posts
    • 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
      Aditya Gupta last edited by

      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)

      SGaist 1 Reply Last reply Reply Quote 0
      • H
        hbatalha last edited by

        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 Reply Quote 1
        • A
          Aditya Gupta last edited by

          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 Reply Quote 0
          • H
            hbatalha @Aditya Gupta last edited by

            @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 Reply Quote 1
            • SGaist
              SGaist Lifetime Qt Champion @Aditya Gupta last edited by

              @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 Reply Quote 4
              • A
                Aditya Gupta last edited by

                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 Reply Quote 0
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

                  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 Reply Quote 2
                  • Chris Kawa
                    Chris Kawa Moderators last edited by

                    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 Reply Quote 2
                    • Kent-Dorfman
                      Kent-Dorfman last edited by

                      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 Reply Quote 0
                      • First post
                        Last post