[patch] WORDSIZE dependant printf length modifiers

Rich Felker dalias at aerifal.cx
Sat Apr 8 21:14:42 UTC 2006


On Sat, Apr 08, 2006 at 04:32:10PM -0400, Robert P. J. Day wrote:
> On Sat, 8 Apr 2006, Rob Landley wrote:
> 
> > On Saturday 08 April 2006 4:43 am, Robert P. J. Day wrote:
> 
> > > and declaring boolean variables as some type of actual "boolean"
> > > definitely improves the code aesthetics and, possibly, type
> > > checking.
> >
> > It somehow improves the code to use a type that has a profoundly
> > undefined representation?
> 
> i'm not sure what the problem is here.  what does the representation
> have to do with anything?  doesn't it make sense that, if you want a
> data type to represent exactly one of two boolean values, you declare
> it as of type "boolean"?  in what way would that be a bad thing?

char a = flag;
bool b = flag;

You would expect these to compile to near-equivalent code, right? But
no. The former is just a mov (or load/store) instruction. The latter
is equivalent to:

char b = flag ? 1 : 0;

i.e. it compiles to a conditional. This is quite bad for code size and
performance...

[At least the above is true according to my interpretation of C99..]

Rich





More information about the busybox mailing list