2

When I compile a simple C++ program like this:

#include<iostream>
using namespace std;
int main()
{
    cout << "hello word" << endl;
    return 0;
}

I got some error message,

This is part of the error message:

In file included from e:\mingw\lib\gcc\mingw32\8.2.0\include\c++\cstdlib:75,
                 from e:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ext\string_conversions.h:41,
                 from e:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\basic_string.h:6391,
                 from e:\mingw\lib\gcc\mingw32\8.2.0\include\c++\string:52,
                 from e:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\locale_classes.h:40,
                 from e:\mingw\lib\gcc\mingw32\8.2.0\include\c++\bits\ios_base.h:41,
                 from e:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ios:42,
                 from e:\mingw\lib\gcc\mingw32\8.2.0\include\c++\ostream:38,
                 from e:\mingw\lib\gcc\mingw32\8.2.0\include\c++\iostream:39,
                 from F:\Desktop\web\web\work_one\test.cpp:1:
e:\mingw\include\stdlib.h:90:1: error: '_BEGIN_C_DECLS' does not name a type
 _BEGIN_C_DECLS
 ^~~~~~~~~~~~~~
e:\mingw\include\stdlib.h:363:1: error: '__CRT_ALIAS' does not name a type
 __CRT_ALIAS __cdecl __MINGW_NOTHROW
 ^~~~~~~~~~~
e:\mingw\include\stdlib.h:367:1: error: '__CRT_ALIAS' does not name a type
 __CRT_ALIAS __cdecl __MINGW_NOTHROW
 ^~~~~~~~~~~
e:\mingw\include\stdlib.h:444:55: error: '_locale_t' has not been declared
 __int64 _wcstoi64_l(const wchar_t *, wchar_t **, int, _locale_t);
                                                       ^~~~~~~~~
e:\mingw\include\stdlib.h:447:65: error: '_locale_t' has not been declared
 unsigned __int64 _wcstoui64_l(const wchar_t *, wchar_t **, int, _locale_t);
                                                                 ^~~~~~~~~
e:\mingw\include\stdlib.h:866:1: error: '_END_C_DECLS' does not name a type
 _END_C_DECLS
 ^~~~~~~~~~~~

This seems to be a problem with the header file syntax, but I did not modify the head file.

I use this command to compile:

g++ -g -std=c++11 F:\Desktop\web\web\work_one\test.cpp -o test.exe

My operating system is Win10.

The g++ version is g++ (MinGW.org GCC-8.2.0-3) 8.2.0

G++ I got from http://www.mingw.org/

ejderuby
  • 710
  • 5
  • 21
Time
  • 21
  • 3

2 Answers2

0

Possible solution to this already exists here

Just change -std=c++11 with -std=gnu++11

SgerS1
  • 131
  • 5
0

Finally, I fixed the problem. The reason for this problem is that I installed codeblocks.

codeblocks adds environment variables to my computer, like C_INCLUDEDE_PATH, CPLUS_INCLUDE_PATH, and LIBRARY_PATH. When I deleted these environment variables, the problem was fixed.

sɐunıɔןɐqɐp
  • 3,332
  • 15
  • 36
  • 40
Time
  • 21
  • 3