[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
output).
So
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
1
is an int, whereas
1L
is a longint. Since ints are 16 bits wide 1 << 16 gives the warning,
while 1L << 16 works fine.
--
Dave Hylands
Vancouver, BC, Canada
http://www.DaveHylands.com/
Re: [avr-libc-dev] RFC: avr/bits.h,
Dave Hylands <=
Re: [avr-libc-dev] RFC: avr/bits.h, Joerg Wunsch, 2005/03/01
Re: [avr-libc-dev] RFC: avr/bits.h, Nicolas Schodet, 2005/03/01
[avr-libc-dev] Addition of a vprintf macro in stdio.h ..? or rather a function ..?, Björn Haase, 2005/03/06