0

I swear to God that I didn't do anything except the usual compiling and running c++ files. All of a sudden my code is refusing to compile both in VScode and gVim, here is the code and the error message

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    cout << "Hello world\n";
}

and the error message while compiling in both VScode and gVim .

C:\WINDOWS\system32\cmd.exe /c (g++ -std=c++14 cses.cpp -o cses -Wl,--stack,268435456)
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\sstream:813:0,
                 from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\complex:45,
                 from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ccomplex:39,
                 from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\stdc++.h:52,
                 from cses.cpp:1:
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\sstream.tcc:45:38: error: '_alloc' was not declared in this scope
     basic_stringbuf<_CharT, _Traits, _alloc>::
                                      ^~~~~~
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\sstream.tcc:45:44: error: template argument 3 is invalid
     basic_stringbuf<_CharT, _Traits, _alloc>::
                                            ^
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\sstream.tcc:46:15: error: 'int_type' was not declared in this scope
     pbackfail(int_type __c)
               ^~~~~~~~
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\sstream.tcc:47:5: error: expected ';' before '{' token
     {
     ^
shell returned 1

What has happened? is my gcc corrupt or what because the code works fine in online compilers?This is actually happening for all C++ files I just noticed

  • 6
    I suggest you start over, and get [some decent books](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) and take a couple of classes to learn C++ properly, rather than learning to create something like the mess you show us from so-called "competition" sites. – Some programmer dude Mar 07 '21 at 17:42
  • that file is irrelevant to my doubt tbh. all c++ files are giving this error. This is just an example code, probably a bad one I agree but syntax error has nothing to do with the logic – Combat Miners Mar 07 '21 at 17:44
  • I hope u like the code now? Its giving the same error – Combat Miners Mar 07 '21 at 17:46
  • 4
    Looks like a broken compiler installation. Doesn't really matter why it broke, maybe you accidentally changed some file. Just uninstall it and get a new one. – HolyBlackCat Mar 07 '21 at 17:48
  • 4
    Now is a good moment to update your compiler. GCC 6.3 is *old*. You can get new shiny GCC 10.2 from https://www.msys2.org/ – HolyBlackCat Mar 07 '21 at 17:48
  • 2
    Suggested reading: https://stackoverflow.com/questions/31816095/why-should-i-not-include-bits-stdc-h – ChrisMM Mar 07 '21 at 17:48
  • Better. Still [a couple](https://stackoverflow.com/questions/31816095/why-should-i-not-include-bits-stdc-h) of [bad habits](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice), but emphasizes the possible broken or bad installation better. – Some programmer dude Mar 07 '21 at 17:49
  • @ChrisMM thanks and I really need to brush up my C++ lol. But I wonder how did that header create a mess all of a sudden? I have been using it for past one year without trouble – Combat Miners Mar 07 '21 at 17:50
  • Ahh another reason not to [#include bits/stdc++.h](https://stackoverflow.com/questions/31816095/why-should-i-not-include-bits-stdc-h)... (There's nothing wrong with your compiler, but mingw never supported bits/stdc++.h). – rustyx Mar 07 '21 at 17:51
  • It did for past one year , how all of a sudden it realized to not do that anymore? – Combat Miners Mar 07 '21 at 17:52
  • @Someprogrammerdude I am a competitive programmer so yea I have got bad habits. Sorry about that lol – Combat Miners Mar 07 '21 at 17:53
  • Did my compiler upgrade itself behind by back and it stopped supporting bits header? – Combat Miners Mar 07 '21 at 17:54
  • 2
    Its unlikely the compiler updated itself, but it's possible something got corrupted. Competitive programming is a joke, and does not teach C++. All it does is teach you horrible habits that would fail even the most cursory of code reviews at a company. – ChrisMM Mar 07 '21 at 18:37
  • I do competitive programming because its fun way to learn algorithms and maths and apply them :( Thanks for the help, I have stopped using bits header and namespace std , I will try to improve my coding practices . Sorry . – Combat Miners Mar 08 '21 at 09:33

0 Answers0