Reputation: 4716
I am currently getting a build error. this error looks like this
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);
Upon investigation I noticed the code in C++Locale.h
looks like this
// Written by Benjamin Kosnik <[email protected]>
#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
Now this error goes away If i change the parameter in the line
inline int
__convert_from_v(const __c_locale&, char* __out,
const int __size __attribute__((__unused__)),
const char* __fmt, ...)
from __out
to something else like __aout
or if I remove the inline keyword. I know i should not be making changes in the default imp. files . This file is in the folder
C:\mingw64\x86_64-w64-mingw32\include\c++\x86_64-w64-mingw32\bits
Any suggestions on what I could do to resolve this issue without making changes to the actual files of Mingw GCC 64 bit?
Upvotes: 1
Views: 1295
Reputation: 17124
It looks like you have a header file of your own that is defining __out
. Just find where it is, and use a different name. Note that identifiers starting with double underscore are reserved in C++
; this is why the parameter names in c++locale.h
start with __
, so they don't clash with anything the user might define. So you shouldn't be using __out
for your own purposes (if indeed that is where the problem lies).
Having said that, nothing bad will happen to you if you edit c++locale.h
to change all instances of __out
to __aout
.
Updated to add: I think Ross Ridge and I have cracked it between us in the comments. This is from the mingw header file 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)
So the definition of __out
makes this header file incompatible with c++locale.h
-- a mingw bug.
Upvotes: 6