This is the mail archive of the
mailing list for the GDB project.
Re: [PATCH] windows-nat: Decode system error numbers
On Wed, Nov 09, 2011 at 06:06:52PM +0100, Corinna Vinschen wrote:
>On Nov 9 16:58, Pedro Alves wrote:
>> On Wednesday 09 November 2011 16:42:50, Eli Zaretskii wrote:
>> > > Date: Wed, 9 Nov 2011 12:02:40 +0000
>> > > From: "Maciej W. Rozycki" <email@example.com>
>> > >
>> > > + const char *msg = "Unspecified error.";
>> > > + unsigned long err;
>> > > + char buf;
>> > > + size_t size;
>> > > +
>> > > + if (ok)
>> > > + return;
>> > > +
>> > > + err = GetLastError();
>> > > + size = FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM
>> > > + | FORMAT_MESSAGE_IGNORE_INSERTS,
>> > > + NULL,
>> > > + err,
>> > > + MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
>> > > + buf, (sizeof (buf) - 1) / sizeof (TCHAR), NULL);
>> > Will this DTRT with Cygwin, which AFAIK wants the wide versions of the
>> > APIs? Is, for example, "char buf;" appropriate in that case?
>> Yeah, if UNICODE is defined, FormatMessage maps to FormatMessageW and
>> buf will be filled with a wide string, though I'm not sure
>> if __USEWIDE implies UNICODE.
>Then again, buf is defined as char, not wchar_t or WCHAR. It would be
>better to make buf a wchar_t, always call FormatMessageW, and then call
>printf_filtered with %ls as string format. That should work on all
With that type of change, this would likely be approved.