1

我是 Cygwin、Windows 和 C++ 的新手,所以请多多包涵。

这是我尝试使用 Cygwin 编译的 C++ 程序 (try.cpp)。

#include<iostream>
using namepsace std;

int main(void) {
        cout<<"Trying out CPP"<<endl;
        return 0;
}

这是我正在使用的 Cygwin 版本(uname -r在 cygwin 终端上使用):1.7.17(0.262/5/3)

这是我用来编译程序的命令: g++ try.cpp

这是我得到的错误:

$ g++ try.cpp
try.cpp:2: error: expected nested-name-specifier before "namepsace"
try.cpp:2: error: `namepsace' has not been declared
try.cpp:2: error: expected `;' before "std"
try.cpp:2: error: expected constructor, destructor, or type conversion before ';' token
try.cpp: In function `int main()':
try.cpp:5: error: `cout' undeclared (first use this function)
try.cpp:5: error: (Each undeclared identifier is reported only once for each function it appears in.)
try.cpp:5: error: `endl' undeclared (first use this function)

FWIW,这就是我做的时候得到的g++ -v(我猜是我电脑上安装的 g++ 版本)”

Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /managed/gcc-build/final-v3-bootstrap/gcc-3.4.4-999/configure --verbose --program-suffix=-3 --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-languages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-gettext --enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-threads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptions --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)

我究竟做错了什么?

4

1 回答 1

3

您拼写错误/输入错误namespacenamepsace.

于 2013-02-18T06:42:49.760 回答