我有一个比较两个字符串的基本程序:
#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 编译?
编辑:人们对堆栈溢出越来越苛刻,直到我犹豫要不要发布一个问题。上面的问题有一个简单的答案,很好,但是因为他们有一个简单但不明显的答案而对问题投反对票(在第一分钟两次!)是正常的吗?