我有一些 C++0x 代码。我能够在下面重现它。下面的代码可以正常工作,-std=c++0x
但我的真实代码不需要它。
如何在 C++0x 中包含 strdup?使用 gcc 4.5.2
注意我正在使用mingw。我尝试包括 cstdlib、cstring、string.h 并尝试使用 std::。没运气。
>g++ -std=c++0x a.cpp
a.cpp: In function 'int main()':
a.cpp:4:11: error: 'strdup' was not declared in this scope
代码:
#include <string.h>
int main()
{
strdup("");
return 0;
}