我目前正在收到构建错误.这个错误看起来像这样
C:/mingw64/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32/bits/c++locale.h: In function 'int std::__convert_from_v(int* const&, char*, int, const char*, ...)':
C:/mingw64/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32/bits/c++locale.h:74:48: error: expected primary-expression before ',' token
const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
Run Code Online (Sandbox Code Playgroud)
经过调查,我注意到代码C++Locale.h看起来像这样
// Written by Benjamin Kosnik <bkoz@redhat.com>
#ifndef _GLIBCXX_CXX_LOCALE_H
#define _GLIBCXX_CXX_LOCALE_H 1
#pragma GCC system_header
#include <clocale>
#define _GLIBCXX_NUM_CATEGORIES 0
namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef int* __c_locale;
// Convert numeric value of type double and long double to string and
// return length of string. If vsnprintf is available use it, otherwise
// fall back to the unsafe vsprintf which, in general, can be dangerous
// and should be avoided.
inline int
__convert_from_v(const __c_locale&, char* __out,
const int __size __attribute__((__unused__)),
const char* __fmt, ...)
{
char* __old = std::setlocale(LC_NUMERIC, 0);
char* __sav = 0;
if (__builtin_strcmp(__old, "C"))
{
const size_t __len = __builtin_strlen(__old) + 1;
__sav = new char[__len];
__builtin_memcpy(__sav, __old, __len);
std::setlocale(LC_NUMERIC, "C");
}
__builtin_va_list __args;
__builtin_va_start(__args, __fmt);
#ifdef _GLIBCXX_USE_C99
const int __ret = __builtin_vsnprintf(__out, __size, __fmt, __args);
#else
const int __ret = __builtin_vsprintf(__out, __fmt, __args);
#endif
__builtin_va_end(__args);
if (__sav)
{
std::setlocale(LC_NUMERIC, __sav);
delete [] __sav;
}
return __ret;
}
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
#endif
Run Code Online (Sandbox Code Playgroud)
现在这个错误消失了如果我改变了行中的参数
inline int
__convert_from_v(const __c_locale&, char* __out,
const int __size __attribute__((__unused__)),
const char* __fmt, ...)
Run Code Online (Sandbox Code Playgroud)
from __outto other like like __aout 或者如果我删除了inline关键字.我知道我不应该在默认imp中进行更改.文件.该文件位于该文件夹中
C:\mingw64\x86_64-w64-mingw32\include\c++\x86_64-w64-mingw32\bits
Run Code Online (Sandbox Code Playgroud)
有关如何在不更改Mingw GCC 64位实际文件的情况下解决此问题的建议?
看起来你有一个自己的头文件正在定义__out.只需找到它的位置,并使用不同的名称.请注意,以双下划线开头的标识符保留在C++; 这就是为什么参数名称以c++locale.hstart开头__,因此它们不会与用户可能定义的任何内容发生冲突.所以你不应该__out为了自己的目的而使用(如果问题确实存在的话).
话虽如此,没有什么大不了的发生在你身上,如果你编辑c++locale.h修改的所有实例__out来__aout.
更新添加:我认为罗斯里奇和我在评论中已经在我们之间破解了它.这是来自mingw头文件i686-w64-mingw32\include\driverspecs.h:
/*
* FIXME: These annotations are not driver-only and does not belong here
*/
#define __in
#define __in_bcount(Size)
#define __in_ecount(Size)
#define __out
#define __out_bcount(Size)
#define __out_bcount_part(Size, Length)
#define __out_ecount(Size)
Run Code Online (Sandbox Code Playgroud)
所以定义__out使这个头文件与c++locale.h- 一个mingw bug 不兼容.