bugAVR C Runtime Library - Bugs: bug #32650, Missing include in util/delay.h

 
 

bug #32650: Missing include in util/delay.h

Submitted by:  Alastair D'Silva <deece>
Submitted on:  Wed 02 Mar 2011 12:15:55 PM UTC  
 
Category: HeaderSeverity: 3 - Normal
Priority: 5 - NormalItem Group: libc code
Status: FixedPercent Complete: 100%
Assigned to: Eric Weddington <arcanum>Open/Closed: Closed
Release: 1.7.*Fixed Release: 1.7.2

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 04 Mar 2011 11:42:46 PM UTC, comment #3:

Please note that this error occurs when the header is included, regardless of whether a constant or a variable is passed (in my case, it was actually a constant), even to the extent that if no calls are made to the delay functions, and the header is included, it fails.

The attached trivial testcase will produce the following error using GCC 4.5.2:

make all
Building file: ../Testcase.cpp
Invoking: AVR C++ Compiler
avr-g++ -I"A:\eclipse\mhvlib" -Wall -Os -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -funsigned-char -funsigned-bitfields -fno-exceptions -mmcu=atmega1280 -DF_CPU=16000000UL -MMD -MP -MF"Testcase.d" -MT"Testcase.d" -c -o"Testcase.o" "../Testcase.cpp"
In file included from ../Testcase.cpp:3:0:
c:\mhvavrtools\bin\../lib/gcc/avr/4.5.2/../../../../avr/include/util/delay.h: In function 'void _delay_ms(double)':
c:\mhvavrtools\bin\../lib/gcc/avr/4.5.2/../../../../avr/include/util/delay.h:149:42: error: 'fabs' was not declared in this scope
c:\mhvavrtools\bin\../lib/gcc/avr/4.5.2/../../../../avr/include/util/delay.h:149:43: error: 'ceil' was not declared in this scope
c:\mhvavrtools\bin\../lib/gcc/avr/4.5.2/../../../../avr/include/util/delay.h: In function 'void _delay_us(double)':
c:\mhvavrtools\bin\../lib/gcc/avr/4.5.2/../../../../avr/include/util/delay.h:226:42: error: 'fabs' was not declared in this scope
c:\mhvavrtools\bin\../lib/gcc/avr/4.5.2/../../../../avr/include/util/delay.h:226:43: error: 'ceil' was not declared in this scope
make: *** [Testcase.o] Error 1

(file #22840)

Alastair D'Silva <deece>
Fri 04 Mar 2011 04:17:04 PM UTC, comment #2:

Is there any way that we can test to see if the parameter is not a constant and then issue an error if it is not a constant?

Doing that would be better than to have weird errors like this.

Eric Weddington <arcanum>
Project AdministratorIn charge of this item.
Fri 04 Mar 2011 04:48:38 AM UTC, comment #1:

The math library is not needed if you do not pass a variable to _delay_ms (or _delay_us) as the instructions to avr-libc warn you not to do. Only constants can be supplied to the delay functions.

In fact, following your path will bring in the floating-point library unnecessarily and will cause the delay functions to generate far more delay that requested.

For more on the use of the delay functions, please read http://www.nongnu.org/avr-libc/user-manual/group__util__delay.html

Stu Bell <stusan_2>
Wed 02 Mar 2011 12:15:55 PM UTC, original submission:

Compiling using gcc 4.5.2 against AVR LibC 1.7.1 results in calls to _delay_ms failing with:

c:\program files (x86)\mhv avr tools\bin\../lib/gcc/avr/4.5.2/../../../../avr/include/util/delay.h: In function 'void _delay_ms(double)':
c:\program files (x86)\mhv avr tools\bin\../lib/gcc/avr/4.5.2/../../../../avr/include/util/delay.h:149:42: error: 'fabs' was not declared in this scope
c:\program files (x86)\mhv avr tools\bin\../lib/gcc/avr/4.5.2/../../../../avr/include/util/delay.h:149:43: error: 'ceil' was not declared in this scope

Adding math.h to the list of includes in util/delay.h fixes the problem.

Alastair D'Silva <deece>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #22840:  Testcase.cpp added by deece (72B - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by arcanum (Posted a comment)
  • -unavailable- added by stusan_2 (Posted a comment)
  • -unavailable- added by deece (Submitted the item)
  •  

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 12 May 2011 02:52:00 AM UTCarcanumStatusNone=>Fixed
      Percent Complete0%=>100%
      Assigned toNone=>arcanum
      Open/ClosedOpen=>Closed
      Fixed ReleaseNone=>1.7.2
    Fri 04 Mar 2011 11:42:46 PM UTCdeeceAttached File-=>Added Testcase.cpp, #22840

    Back to the top


    Powered by Savane 3.1-cleanup1