0

I was compiling bits/stdc++.h header included with mingw-w64 in using

g++ -std=c++17 stdc++.h

I got a list of errors ending with

C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/fs_path.h:167:5: note: no known conversion for argument 1 from 'std::basic_string_view<wchar_t>' to 'std::filesystem::__cxx11::path&&'

C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/fs_path.h:165:5: note: candidate: 'std::filesystem::__cxx11::path::path(const std::filesystem::__cxx11::path&)' path(const path& __p) = default; ^~~~

C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/fs_path.h:165:5: note: no known conversion for argument 1 from 'std::basic_string_view<wchar_t>' to 'const std::filesystem::__cxx11::path&'

C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/fs_path.h:163:5: note: candidate: 'std::filesystem::__cxx11::path::path()' path() noexcept { } ^~~~

C:/MinGW/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/fs_path.h:163:5: note: candidate expects 0 arguments, 1 provided

but on compiling with

g++ -std=c++14 stdc++.h

it get's precompiled

Is there any way to precompile it with c++17 ?

Amish
  • 197
  • 1
  • 11
  • Why do you want to precompile some non-standard header? – Evg Jan 23 '22 at 08:28
  • Yes but It is included with mingw-w64. It is used in competitive programming etc. – Amish Jan 23 '22 at 08:29
  • What do you mean by "included"? An end user is not supposed to use headers that are internal to a standard library implementation. – Evg Jan 23 '22 at 08:30
  • 2
    @Evg GCC manual advises you do exactly this. https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_headers.html – HolyBlackCat Jan 23 '22 at 08:31
  • 7
    Generally: [Why should I not #include ?](https://stackoverflow.com/questions/31816095/why-should-i-not-include-bits-stdc-h) As long as you don't `#include` it yourself it's fine. – Some programmer dude Jan 23 '22 at 08:32
  • 7
    And so-called "competitive programming" sites are ***not*** any kind of learning or teaching resource. Using them as such could instead be actively harmful for your learning. Their examples are usually bad and often invalid as well. Learn programming and a few languages *first*, before ever looking at such sites. – Some programmer dude Jan 23 '22 at 08:33
  • 1
    @Amish GCC 8 is a bit outdated. I wouldn't be surprised if the `` header was broken in it. I've just tried `g++ -std=c++17 stdc++.h` on GCC 11 from MSYS2, and it worked correctly. – HolyBlackCat Jan 23 '22 at 08:38
  • Precompiling it with c++17 in MinGW is working but in mingw-w64 it is generating errors? – Amish Jan 23 '22 at 08:38
  • @HolyBlackCat so I should use MSYS2 then ? – Amish Jan 23 '22 at 08:40
  • Yes, I'd recommend using MSYS2 regardless of precompiled headers. – HolyBlackCat Jan 23 '22 at 08:41
  • Is there any benefit of precompiling headers ? – Amish Jan 23 '22 at 08:43
  • 4
    Competitive coding sites do train your problem solving skills but they also teach horrible coding styles (really!). If you want to learn C++, learn that first. If you can't get your hands om some recent C++ books (at least covering C++11 in detail preferable newer) then you can start learning more on C++ here : https://www.learncpp.com/. Right after that a good read is : https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines – Pepijn Kramer Jan 23 '22 at 08:44
  • 2
    Precompiled headers can speed up compilation speeds, they're like a cache so that the compiler doesn't have to reparse them on the next compile (provided the header files didn't change) – Pepijn Kramer Jan 23 '22 at 08:44
  • 3
    *"Is there any benefit of precompiling headers?"* If you don't know that, why are you trying to do it? :) Yes, they're supposed to improve build times. – HolyBlackCat Jan 23 '22 at 08:45
  • @HolyBlackCat Yeah I was just confirming it Thanks :) – Amish Jan 23 '22 at 08:48
  • 5
    But for competitive programming site type code -- they would be practically worthless. Instead of picking up bad habits trying to learn from those sites, stop by [The Definitive C++ Book Guide and List](https://stackoverflow.com/q/388242/3422102) and learn C++, then go exercise your problem solving skills. – David C. Rankin Jan 23 '22 at 08:50
  • I am very against the header `bits/stdc++.h` for "competitive programming" or other uses. But `stdc++.h` is *designed* to be used as precompiled header, so this question makes sense, provided you only build with GCC. – prapin Jan 23 '22 at 10:18

0 Answers0