When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

ivanz's blog

By ivanz, history, 2 years ago, translation, In English

Hello! I ran into a following problem. I downloaded Code::Blocks 20.03 MinGW version here. If I select C++14 and try to compile program using bits/stdc++ everything is OK.

But when I select C++17 a mistake occurs:

If I don't use bits/stdc++.h but include the libraries separately everything works with C++14 and with C++17. So the problem is exactly in this library. What I need to do to make bits/stdc++ working with C++17?

UPD: this helps:
#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>

  • Vote: I like it
  • +29
  • Vote: I do not like it

| Write comment?
»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Hey, I would recommend you using VS Code as it comes easy to use, with many cool extension support and much larger community base.

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I am thinking about starting to use other IDEs, but I would also like to understand what the problem is in this case.

    • »
      »
      »
      2 years ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      You could try switching to other GCC builds, no need to change IDE. One of those I have installed works with bits/stdc++ and another doesn't. This should be the link to the one that does, but I had other issues with it (unrelated to competitive programming).

      • »
        »
        »
        »
        2 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I see, thanks for the advice!

»
2 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Try selecting ISO instead of GNU? I used to use Code::Blocks way back in the day and ISO C++17 worked fine.

  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Unfortunately, it doesn't work either way. But using C++14 both (ISO and GNU) work fine.
    But #define _GLIBCXX_FILESYSTEM helps.

»
2 years ago, # |
  Vote: I like it +14 Vote: I do not like it

Use this to show that you already include <filesystem> that produce this complitation error:

#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
  • »
    »
    2 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks, this works! But can you explain why i don't need to write this while using C++14?

    • »
      »
      »
      2 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      filesystem library was introduced in C++17.

»
15 months ago, # |
  Vote: I like it +8 Vote: I do not like it

Thank you so much. This two-line code is working

#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>

Thank you ivanz