2 つの文字列を比較する基本的なプログラムがあります。
#include <string>
#include <iostream>
using namespace std;
int main (int argc, char *argv[]) {
if(strcmp (argv[0],"./test") != 0) {
cout << "not equal" << endl;
} else {
cout << "equal" << endl;
}
return 0;
}
gcc でコンパイルされますが、 clang ではコンパイルされません:
> clang -o test test_clang.cpp
test_clang.cpp:7:6: error: use of undeclared identifier 'strcmp'
if(strcmp (argv[0],"./test") != 0) {
^
1 error generated.
なぜ clang でコンパイルしないのですか?
編集:私が質問を投稿するのをためらうまで、人々はスタックオーバーフローに厳しくなっています。上記の質問には簡単な答えがありますが、質問に反対票を投じるのは普通ですか (最初の 1 分間に 2 回!)。