From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8342 invoked by alias); 13 Nov 2011 23:47:58 -0000 Received: (qmail 8334 invoked by uid 22791); 13 Nov 2011 23:47:57 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from nm29-vm0.access.bullet.mail.mud.yahoo.com (HELO nm29-vm0.access.bullet.mail.mud.yahoo.com) (66.94.236.255) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Sun, 13 Nov 2011 23:47:44 +0000 Received: from [66.94.237.195] by nm29.access.bullet.mail.mud.yahoo.com with NNFMP; 13 Nov 2011 23:47:43 -0000 Received: from [66.94.237.102] by tm6.access.bullet.mail.mud.yahoo.com with NNFMP; 13 Nov 2011 23:47:43 -0000 Received: from [127.0.0.1] by omp1007.access.mail.mud.yahoo.com with NNFMP; 13 Nov 2011 23:47:43 -0000 Received: (qmail 55713 invoked from network); 13 Nov 2011 23:47:43 -0000 X-Yahoo-SMTP: jenXL62swBAWhMTL3wnej93oaS0ClBQOAKs8jbEbx_o- Received: from cgf.cx (cgf@98.110.183.46 with login) by smtp102.vzn.mail.bf1.yahoo.com with SMTP; 13 Nov 2011 15:47:43 -0800 PST Received: from localhost (ednor.casa.cgf.cx [192.168.187.5]) by cgf.cx (Postfix) with ESMTP id C28DE13C0D3 for ; Sun, 13 Nov 2011 18:46:27 -0500 (EST) Date: Sun, 13 Nov 2011 23:47:00 -0000 From: Christopher Faylor To: gdb-patches@sourceware.org Subject: Re: [PATCH] windows-nat: Decode system error numbers Message-ID: <20111113234627.GA5363@ednor.casa.cgf.cx> Mail-Followup-To: gdb-patches@sourceware.org References: <83obwlgsc5.fsf@gnu.org> <201111091658.00913.pedro@codesourcery.com> <20111109170652.GM15154@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20111109170652.GM15154@calimero.vinschen.de> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-11/txt/msg00345.txt.bz2 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" >> > > >> > > + 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