Skip to content

wiring.h round macro causes error with avr-libc-1.7.1 fix [imported] #604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cmaglie opened this issue Nov 15, 2012 · 1 comment
Closed
Assignees

Comments

@cmaglie
Copy link
Member

cmaglie commented Nov 15, 2012

This is Issue 604 moved from a Google Code project.
Added by 2011-08-28T17:03:46.000Z by [email protected].
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Defect, Priority-Medium

Original description

I am debugging routines in the Linux avr-gcc compiler.

I found and corrected a bug in the avr-libc-1.7.1 delay.h file, but the solution caused a problem with the round() function in math.h. Here is the report to Savannah on the delay.h bug.
https://savannah.nongnu.org/bugs/?34047

Here is a section of a post to the Arduino forum, so I don't have to retype it. Bug #2 is the bug affecting the Arduino library. Past versions of avr-libc may need that round macro, but not 1.7.1. It generates an error with that version.

Bug #1
avrlibc-1.7.1/include/util/delay.h.in

At line 44, add this:
Code:

include <math.h>

This is required due to the calls to fabs() and ceil() in the delay.h file.

If you are using a precompiled version from a repository or download from Atmel, you can "retro" this fix by adding the same line to your current delay.h file.
/usr/../avr/include/util/delay.h
My repository installed it in "/usr/avr/include/util/delay.h", but that could vary by version of Linux and the repository. Some may be "/usr/local/".

Bug #2
arduino-0022/hardware/arduino/cores/arduino/wiring.h
Remark out line 79 (round macro). This causes a problem with the avr-gcc math.h library when you add the include to delay.h.
Code:

// #define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

@sandeepmistry
Copy link
Contributor

Closing, I don't think this is an issue anymore, latest AVR toolchain is using AVR libc v1.8.0.

avr/include/avr/version.h:58:#define __AVR_LIBC_VERSION_STRING__ "1.8.0svn"
avr/include/avr/version.h:68:#define __AVR_LIBC_VERSION__        10800UL

debiatan pushed a commit to debiatan/cyrano that referenced this issue Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants