[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] RFC: avr/bits.h

From: Dave Hylands
Subject: Re: [avr-libc-dev] RFC: avr/bits.h
Date: Tue, 1 Mar 2005 09:23:03 -0800

Hi Bob,

> I wanted to do a test case for using bit_XXX on longs to see if it does the
> right thing, and wrote the following test case.  However the results to me
> are puzzling, they look down right broken.  What is going on here?:

Part of the problem is that bit_set wants a bit number, and you're
providing a bit mask (I was fooled until I looked at the preprocessor


    bit_set( shorttest_u16, BIT(4) ); 

should really be 

    bit_set( shorttest_u16, 4 );

Then it doesn't fail until

   bit_set( longtest_u32, 16 );

which happens because


is an int, whereas


is a longint. Since ints are 16 bits wide 1 << 16 gives the warning,
while 1L << 16 works fine.

Dave Hylands
Vancouver, BC, Canada

reply via email to

[Prev in Thread] Current Thread [Next in Thread]