【发布时间】:2013-01-25 09:47:08
【问题描述】:
当我使用 g++ 的-std=c++0x 参数时,我想使用string.h 中缺少的strlcpy(调用外部api)。
% g++ -std=c++0x foo.cpp
foo.cpp: In function 'int main(int, char**)':
foo.cpp:5:11: error: 'strlcpy' was not declared in this scope
% g++ foo.cpp
% cat foo.cpp
#include <string.h>
int main(int argc, char* argv[])
{
const char src[] = "foo";
char dest[1024] = { 0 };
strlcpy(dest, src, sizeof(dest));
return 0;
}
是否可以使用strlcpy 和std=c++0x 标志,还是我必须放弃后者?
此外,我无法在 cygwin 中找到 strlcpy 联机帮助页,尽管它们似乎具有该功能。有什么指点吗?
我在 cygwin 上使用 gcc 4.7.2。
【问题讨论】: