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 -rcygwin端末で使用して取得):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

のようにスペル/ミスタイプnamespaceしましnamepsaceた。

于 2013-02-18T06:42:49.760 に答える