我正在尝试构建DAME。环境细节:
GCC - gcc版本4.4.2(GCC) ANTLR - ANTLR分析器生成器2.7.2版
当我尝试编译以下代码片段时:
#include <functional>
#include <iomanip>
struct compare_without_case_char : public std::binary_function<char, char, bool>
{
const std::ctype<char>& ct ;
compare_without_case_char (const std::ctype<char>& c = std::use_facet<std::ctype<char> > (std::locale::classic()))
: ct(c) {}
bool operator() (char x, char y) const
{
return (ct.toupper(x) == ct.toupper(y)) ;
}
} ;
发生以下错误:
test_ctype.cpp: In member function 'bool compare_without_case_char::operator()(char, char) const':
test_ctype.cpp:16: error: invalid use of incomplete type 'const struct std::ctype<char>'
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/localefwd.h:115: error: declaration of 'const struct std::ctype<char>'
test_ctype.cpp:16: error: invalid use of incomplete type 'const struct std::ctype<char>'
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/localefwd.h:115: error: declaration of 'const struct std::ctype<char>'
In file included from /storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/locale_classes.h:809,
from /storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/ios_base.h:43,
from /storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/iomanip:42,
from test_ctype.cpp:2:
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/locale_classes.tcc: In function 'const _Facet& std::use_facet(const std::locale&) [with _Facet = std::ctype<char>]':
test_ctype.cpp:11: instantiated from here
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/locale_classes.tcc:107: error: incomplete type 'std::ctype<char>' used in nested name specifier
/storage11/oracle/ANAND_BM/gcc-4.4.2/gcc_4_4_2_release/gcc-4.4.2_build/lib/gcc/sparc-sun-solaris2.10/4.4.2/../../../../include/c++/4.4.2/bits/locale_classes.tcc:112: error: cannot dynamic_cast '* *(__facets + ((unsigned int)(((unsigned int)__i) * 4u)))' (of type 'const class std::locale::facet') to type 'const struct std::ctype<char>&' (target is not pointer or reference to complete type)
什么是真正的问题以及如何解决它。 问候, Anand Kumar Keshri
答案 0 :(得分:1)
这里唯一的问题是你的编译器找不到std::ctype
。你必须#include包含它的文件:
#include <locale>