RE: [RFA record/replay] cast to avoid compiler warning

Michael Snyder
2008-10-05T15:47:04Z

Yes, but we don't know that gdb will always be built using gnulib.

Mark, I recognize your objection, and I'll change it with some reluctance,
but I really think you're making too big a deal out of it...

________________________________________
From: gdb-patches-owner@sourceware.org [gdb-patches-owner@sourceware.org] On Behalf Of Mark Wielaard [mark@klomp.org]
Sent: Sunday, October 05, 2008 5:16 AM
To: Mark Kettenis
Cc: Michael Snyder; gdb-patches@sourceware.org; teawater@gmail.com
Subject: Re: [RFA record/replay] cast to avoid compiler warning

On Sat, 2008-10-04 at 23:52 +0200, Mark Kettenis wrote:
> > Date: Sat, 04 Oct 2008 11:42:47 -0700
> > From: Michael Snyder <msnyder@vmware.com>
> >
> > Sizeof returns size_t, which is not always the same as int.
> > This cast will prevent compiler warnings on some architectures
> > (eg. x86_64)
>
> This is wrong! Better cast to unsigned long and print as %lu.
>
> There is a C99 way to do this, but not all systems implement it properly.

gnulib provides a posix compatible printf that understands %z for
size_t:
http://www.gnu.org/software/gnulib/manual/html_node/printf.html

Cheers,

Mark