这个程序用VC编译没问题,但是用mingw develop studio编译出现以下错误:
In file included from C:\MinGWStudio\MinGW\include\c++\3.3.1\backward\iostream.h:31,
from ggg.cpp:1:
C:\MinGWStudio\MinGW\include\c++\3.3.1\backward\backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated.
ggg.cpp: In function `char* fun(STRU*, int)':
ggg.cpp:30: error: name lookup of `i' changed for new ISO `for' scoping
ggg.cpp:22: error: using obsolete binding at `i'
ggg.cpp: At global scope:
ggg.cpp:45: error: `main' must return `int'
ggg.cpp:45: error: return type for `main' changed to `int'
ggg.o - 4 error(s), 1 warning(s)
[ Last edited by nono2009 on 2010-11-11 at 07:31 ]
从目前的编译信息来看:
warning: #warning This file includes at least one deprecated or antiquated header.
你这段代码包含了不赞成的或者是老标准的文件头,
Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard.
参看 C++ Standard 的 17.4.1.2 (我看了,里面没有 .h )
Examples include substituting the header for the header for C++ includes, or instead of the deprecated header .
用<******>代替<******.h>(把.h去掉),
或者用代替
To disable this warning use -Wno-deprecated.
编译器版本的问题,目前的信息看来。
根据编译的信息作修改先,不行的话去看 C++ standard 的 17.4.1.2 部分的内容。
再不行的话,帖出编译信息。
---------------------------另:
刚才我在虚拟机里装了个WinGW 2.05,
重现了你的代码错误,
C:\MinGWStudio\MinGW\include\c++\3.3.1\backward\backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the header for the header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated.