【发布时间】:2011-11-23 08:18:46
【问题描述】:
我在这里面临的主要问题是strtoll() 在 VC 2010 (error C3861: 'strtoll': identifier not found) 中被标记为错误。如果我用strtol()替换它会做同样的事情吗?
unsigned int get_uintval_from_arg(int argc, int index, char **argv,
unsigned int lower_bound, unsigned int upper_bound)
{
unsigned int return_val=0;
if (index + 1 <= argc - 1)
{
return_val=(unsigned int)strtoll(argv[index+1],NULL,10);
if (errno == EINVAL || errno== ERANGE)
{
fprintf(stderr, "Could not parse argument %s for switch %s!\n",
argv[index], argv[index+1]);
return 0;
}
}
// ....... I will post the remaining part of the code if necessary
.......
}
【问题讨论】:
-
你在你的程序中有
#include <stdlib.h>吗?既然long long比unsigned long长得多,为什么要尝试使用long long变体? -
long long是最新的 ISO 9899:99 C 标准“C99”的一部分,Microsoft 不支持该标准。 Visual Studio 仅支持从 1990 年开始已有 21 年历史的 C 标准。
标签: c visual-studio-2010 strtol