C++ g++ 错误:预处理指令无效#INCLUDE

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18195806/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 21:47:51  来源:igfitidea点击:

g++ error: invalid preprocessing directive #INCLUDE

c++windowscompiler-errorsg++

提问by Jellypox

I tried testing MinGW under Windows 7 with a simple Hello World program and got the following errors:

我尝试使用一个简单的 Hello World 程序在 Windows 7 下测试 MinGW 并得到以下错误:

C:\code\helloworld.cpp:2:2: error: invalid preprocessing directive #INCLUDE
C:\code\helloworld.cpp:3:7: error: expected neested-name-specifier before 'namespace'
C:\code\helloworld.cpp:3:17: error: expected ';' before 'std'
C:\code\helloworld.cpp:3:17: error: 'std' does not name a type
C:\code\helloworld.cpp: In function 'int main()':
C:\code\helloworld.cpp:7:2: error: 'cout' was not declared in this scope

My original code was as follows:

我的原始代码如下:

//Hello, World
#INCLUDE <iostream>
using namesapce std;

int main()
{
    cout << "Hello, world!";
    return 0;
}

回答by David Elliman

#includeshould be lower case. C++ is case sensitive.

#include应该是小写。C++ 区分大小写。

回答by LukeCodeBaker

#include <iostream>
using namespace std;

int main()
{
   cout << "Hello, world!";
   return 0;
}

回答by Jacob

It should be lowercase. Use #include.

它应该是小写的。使用#include.

Also, it's using namespace std;(typo in namespace).

此外,它是using namespace std;(错别字namespace)。