Dev-C++编译错误
我想使用“Dev-C++”来编译c++代码。 所以我下载并安装它,并编写以下代码:
#include <iostream.h>
main () {
cout << "124";
}
但是当我编译它时,它说:
包含在文件中 E:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31, 来自 [我的文件路径]\Untitled1.cpp:1: E:/Dev-Cpp/include/c++/3.4.2/backward/backward_warning.h:32:2: 警告:#warning 该文件包括 至少一项已弃用或过时 标头。请考虑使用其中之一 节中找到的 32 个标头 C++ 标准的 17.4.1.2。示例包括替换标题 对于 C++ 包含的标头, 或者代替 已弃用的标头。到 禁用此警告使用 -Wno-已弃用。
看到错误后,我将代码更改为以下代码:
#include <iostream>
main () {
cout << "124";
}
但它又说错误。
我在 Turbo C++ 中轻松编译第一个代码,但在 Dev-C++ 中编译......
我能做什么?
I want to use "Dev-C++" for compile c++ codes.
So I download and install it, and write this code:
#include <iostream.h>
main () {
cout << "124";
}
but when I compiled it, it said:
In file included from
E:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31,
from [myfile path]\Untitled1.cpp:1:
E:/Dev-Cpp/include/c++/3.4.2/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.
After I saw errors, I change my code to this code:
#include <iostream>
main () {
cout << "124";
}
but it said again that errors.
I compile first code easily in Turbo C++, BUT in Dev-C++ ...
What can I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,确保写出
main
的完整定义,包括int
返回类型。忽略返回类型是一种古老的、过时的做法,现在已经行不通了。其次,在新式标头中(缺少
.h
扩展名的标头),标准库位于std
命名空间下。有两种方法可以使您的程序正常运行:1.向
cout
添加std::
限定符。2. 添加
using
声明以允许对std
命名空间进行非限定引用。First, make sure you write out the full definition of
main
, including theint
return type. Leaving out the return type is an old, antiquated practice which doesn't fly these days.Second, in the new-style headers—the ones missing the
.h
extension—the standard library is under thestd
namespace. There are two ways to make your program work:1. Add an
std::
qualifier tocout
.2. Add a
using
declaration to allow unqualified references to thestd
namespace.确保将
int
放在main () {
前面我相信 POSIX 需要任何 C/C++ 程序的
main()
函数适当的语言标准返回一个int
(如果我错了,有人纠正我)。编辑:此外,请务必在
int main ()
上方包含using namespace std;
。Make sure you put
int
in front ofmain () {
I believe any C/C++ program's
main()
function is required by POSIX and the appropriate language standards to return anint
(someone correct me if I'm wrong).EDIT: Also, be sure to include
using namespace std;
aboveint main ()
.