error: C2039: 'iswspace' : is not a member of 'std', but std::isspace() compiles fine
error: C2039: 'iswspace' : is not a member of 'std', but std::isspace() compiles fine
我在 VS2008 中遇到了这个奇怪的行为,我可以在一个新的项目中重现这个代码:
#include <cctype>
using namespace std;
int main() {
isspace(' ');
iswspace(L' ');
std::isspace(' ');
std::iswspace(L' '); // <--- ONLY THIS LINE has error
return 0;
}
std::isspace
和 iswspace
不会导致编译错误,但 std::iswspace()
会。
我不明白为什么 std::isspace()
会成为 std 的成员,而 std::iswspace()
却不是。我怀疑这是符合标准的行为。
你需要#include <cwctype>
.
至于为什么非标准的能用,它们是旧版本。 <cctype>
只是 ctype.h
,其中包含 iswspace
的旧版本。参见 msdn:https://msdn.microsoft.com/en-us/library/y13z34da.aspx
我在 VS2008 中遇到了这个奇怪的行为,我可以在一个新的项目中重现这个代码:
#include <cctype>
using namespace std;
int main() {
isspace(' ');
iswspace(L' ');
std::isspace(' ');
std::iswspace(L' '); // <--- ONLY THIS LINE has error
return 0;
}
std::isspace
和 iswspace
不会导致编译错误,但 std::iswspace()
会。
我不明白为什么 std::isspace()
会成为 std 的成员,而 std::iswspace()
却不是。我怀疑这是符合标准的行为。
你需要#include <cwctype>
.
至于为什么非标准的能用,它们是旧版本。 <cctype>
只是 ctype.h
,其中包含 iswspace
的旧版本。参见 msdn:https://msdn.microsoft.com/en-us/library/y13z34da.aspx