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

g++ error: invalid preprocessing directive #INCLUDE

本文关键字:#INCLUDE 无效 指令 预处理 错误 g++      更新时间:2023-10-16

我试着用一个简单的Hello World程序在Windows 7下测试MinGW,结果出现了以下错误:

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

我最初的代码如下:

//Hello, World
#INCLUDE <iostream>
using namesapce std;
int main()
{
    cout << "Hello, world!";
    return 0;
}

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

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

此外,它是using namespace std;namespace中的拼写错误)。

#include <iostream>
using namespace std;
int main()
{
   cout << "Hello, world!";
   return 0;
}