C++
なんだかめんどくさいなぁ
コンパイルが通るとか通らないとか
何だよぅ。エラーが気持ち悪いんだよぅ。
曰く
make -k all
Building file: ../s1.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"s1.d" -MT"s1.d" -o"s1.o" "../s1.cpp"
In file included from /usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/backward/iostream.h:31,
from ../s1.cpp:1:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/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 theheader for the header for C++ includes, or instead of the deprecated header . To disable this warning use -Wno-deprecated.
../s1.cpp:7:9: warning: no newline at end of file
Finished building: ../s1.cpp
Building target: c++.exe
Invoking: GCC C++ Linker
g++ -o"c++.exe" ./s1.o
Finished building target: c++.exe
Build complete for project c++
その昔、C++標準に仕様変更が有りました。その時に、
・標準ライブラリのクラス/関数/変数には全て、頭に std:: を付けるようにする。
・C++標準のヘッダ<〜.h>は、.hを取って<〜>とする。(例:)
・C標準のヘッダ<〜.h>は、とする。(例: ) という3つの事が決まりました。つまり新しい仕様でのHello worldは、
#include
int main(){
std::cout << "Hello world." << std::endl;
return 0;
}となります。でも、いちいち std:: を付けるのは面倒なので、 using namespace std; と書けば、それ以降は std:: を省略できます。
#include
using namespace std;int main(){
cout << "Hello world." << endl;
return 0;
}昔のC++の入門書に書かれていた
#include
int main(){
cout << "Hello world." << endl;
return 0;
}は、今や「正しいC++のコードではない」ので、注意してください。といっても、互換性のために、ほとんどのコンパイラは今でもこのコードを通します。
http://gimite.net/bcbqtree/qtreemain.cgi?mode=thread&thread=220
いや、2000以前の教科書はあれか。古い仕様なのか?知らんし。
Cygwin使ってるからこんな目に遭うのでしょうか?
15分ほど焦った。