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

 
 

You are not allowed to post comments on this tracker with your current authentication level.

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

Submitter:  Alastair D'Silva <deece>
Submitted:  Wed 02 Mar 2011 12:15:55 PM UTC
   
 
Category:  Header Severity:  3 - Normal
Priority:  5 - Normal Item Group:  libc code
Status:  Fixed Assigned to:  arcanum
Percent Complete:  100% Open/Closed:  Closed
Release:  1.7.* Fixed Release:  1.7.2

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>
Group administrator
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.)

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
  • -email is unavailable- added by arcanum (Posted a comment)
  • -email is unavailable- added by stusan_2 (Posted a comment)
  • -email is unavailable- added by deece (Submitted the item)
  •  

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-05-12 arcanum StatusNone Fixed
        Percent Complete0% 100%
        Assigned toNone arcanum
        Open/ClosedOpen Closed
        Fixed ReleaseNone 1.7.2
    2011-03-04 deece Attached File- Added Testcase.cpp, #22840

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code