Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Christopher Faylor <cgf-use-the-mailinglist-please@sourceware.org>
To: gdb-patches@sourceware.org
Subject: Re: [PATCH] windows-nat: Decode system error numbers
Date: Sun, 13 Nov 2011 23:47:00 -0000	[thread overview]
Message-ID: <20111113234627.GA5363@ednor.casa.cgf.cx> (raw)
In-Reply-To: <20111109170652.GM15154@calimero.vinschen.de>

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" <macro@codesourcery.com>
>> > > 
>> > > +  const char *msg = "Unspecified error.";
>> > > +  unsigned long err;
>> > > +  char buf[1025];
>> > > +  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[1025];" 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
>supported platforms.

With that type of change, this would likely be approved.

cgf


      reply	other threads:[~2011-11-13 23:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-09 12:03 Maciej W. Rozycki
2011-11-09 15:25 ` Joel Brobecker
2011-11-09 16:45 ` Eli Zaretskii
2011-11-09 16:58   ` Pedro Alves
2011-11-09 17:03     ` Eli Zaretskii
2011-11-09 17:26       ` Pedro Alves
2011-11-09 17:07     ` Corinna Vinschen
2011-11-13 23:47       ` Christopher Faylor [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111113234627.GA5363@ednor.casa.cgf.cx \
    --to=cgf-use-the-mailinglist-please@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox