C++,错误:尚未声明'__locale_t'

C++, error: '__locale_t' has not been declared

本文关键字:locale 未声明 错误 C++      更新时间:2023-10-16

我是c++的新手,当我包含一些头文件时,我得到了error: '__locale_t' has not been declared,如#include "ruby.h", #include <string.h>等,但#include <stdio.h>没有问题,我在Linux下使用eclipse, #include "ruby.h"#include <string.h>的详细错误是:

/usr/include/string.h:548: error: '__locale_t' has not been declared
/usr/include/string.h:549: error: nonnull argument references non-pointer operand (argument 1, operand 3)
/usr/include/string.h:552: error: '__locale_t' has not been declared
/usr/include/string.h:553: error: nonnull argument references non-pointer operand (argument 1, operand 4)

包含的顺序为:

#include "Abc.h"
#include <string.h>
#include "ruby.h"
#include <stdio.h>

其中Abc为类名。

这是Abc类,除了include:

没有添加任何内容
#include "Abc.h"
#include <stdio.h>
#include <string.h>
#include "ruby.h"
#include "ose_gw.h"
namespace a {
Abc::Abc() {
    // TODO Auto-generated constructor stub
}
Abc::~Abc() {
    // TODO Auto-generated destructor stub
}
} /* namespace a */

尝试编译:

g++ -D__USE_XOPEN2K8 ...

(另见https://sourceware.org/bugzilla/show_bug.cgi?id=10456,其中提到xlocale.h仅在定义__USE_XOPEN2K8时才包含在string.h中)

这显然是一个已知的问题,它被记录为错误,但实际上是某种微妙的配置错误。

见https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52922

我是一个Windows用户,这不是我的能力范围,但答案在某处(我认为)。