avr-chat
[Top][All Lists]
Advanced

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

Re: [avr-chat] ensuring that _delay_us() gets a compile-time double cons


From: Britton Kerin
Subject: Re: [avr-chat] ensuring that _delay_us() gets a compile-time double constant
Date: Tue, 2 Dec 2014 16:35:10 -0900

On Tue, Dec 2, 2014 at 3:36 PM, Michael Hennebry
<address@hidden> wrote:
> On Tue, 2 Dec 2014, Britton Kerin wrote:
>
>> 1.  Does _delay_us() need a double const, or is an int const guaranteed
>>    to work?    The avr libc manual just says "known const" in one place,
>>    but the signature     calls for a double.
>
>
> _delay_us needs a double const.
> It will get a double whether you give it a double or some other number.
> That is what prototypes are for.
> Prototypes are ordinary C.

Yes, but in many cases the type coercian for that happens at run-time.

>>    In file included from one_wire_slave.c:8:0:
>>    /home/bkerin/opt/avr/avr/include/util/delay.h: In function
>> ‘ows_write_bit’:
>>    /home/bkerin/opt/avr/avr/include/util/delay.h:163:28: error:
>> __builtin_avr_delay_cycles expects a compile time integer constant
>>      __builtin_avr_delay_cycles(__ticks_dc);
>
>
> My guess is that a variable or a non-constant
> expression was passed to _delay_us.

Yes, sorry I wasn't clear:  This was what happens when I pass a known
non-const.  I'm just wondering if this trap is dependable, and if it catches
non-double consts, if that's an issue.

Britton



reply via email to

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