Skip to content
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

round in math.h causes compile error with avr-gcc version 4.5.3 #29

Closed
GoogleCodeExporter opened this issue Apr 1, 2016 · 9 comments
Closed

Comments

@GoogleCodeExporter
Copy link

After upgrading to Ubuntu Ocelot (11.10), projects targeted for ATtinys will 
not compile due to an error with the round function in math.h. This probelm is 
when using Arduino IDE v022. 

The round function is duplicated by a macro in wiring.h. Even though this macro 
has been around forever, and for some strange reason still works when targeting 
ATmega chips, it causes the compiler to choke for ATtiny chips. 

Simply commenting out the line (136) in wiring.h:

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


fixes the problem.

Original issue reported on code.google.com by providey...@gmail.com on 2 Nov 2011 at 4:14

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author


Thank you for taking the time to post this issue.

What is the error message?

Original comment by arduino....@gmail.com on 2 Nov 2011 at 5:25

@GoogleCodeExporter
Copy link
Author

In file included from 
/usr/lib/gcc/avr/4.5.3/../../../avr/include/util/delay.h:44:0,
                 from /usr/lib/gcc/avr/4.5.3/../../../avr/include/avr/delay.h:37,
                 from /home/scott/Arduino Sketches/hardware/tiny/cores/tiny/wiring_private.h:32,
                 from /home/scott/Arduino Sketches/hardware/tiny/cores/tiny/WInterrupts.c:37:
/usr/lib/gcc/avr/4.5.3/../../../avr/include/math.h:426:15: error: expected 
identifier or ‘(’ before ‘double’
/usr/lib/gcc/avr/4.5.3/../../../avr/include/math.h:426:15: error: expected 
‘)’ before ‘>=’ token

Original comment by providey...@gmail.com on 2 Nov 2011 at 5:53

@GoogleCodeExporter
Copy link
Author

I'm getting the same error with 

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

already commented out. 
arduino 0022 on Ubuntu 11.10

any ideas?

Original comment by zacharyM...@gmail.com on 26 Nov 2011 at 5:38

@GoogleCodeExporter
Copy link
Author

ah, got it!

to all who encounter the same problem be careful that it is 
/whatever/hardware/attiny45_85/cores/attiny45_85/wiring.h that gets the change, 
 /whatever/arduino/hardware/arduino/cores/arduino/wiring.h is the one that 
doesn't matter. took me a while to realize the ide was referencing a different 
wiring.h when configured to program an attiny 

Original comment by zacharyM...@gmail.com on 26 Nov 2011 at 8:20

@GoogleCodeExporter
Copy link
Author

I found I had to edit math.h and add 
#undef round
as line 426 as per http://forums.reprap.org/read.php?146,107925,107925,quote=1

Original comment by chrom...@gmail.com on 27 Dec 2011 at 4:38

@GoogleCodeExporter
Copy link
Author

I also just added an #undef in math.h as well, which should address all targets.

And this is an issue under OSX as well.

Original comment by alcoholi...@gmail.com on 17 Aug 2012 at 10:55

@GoogleCodeExporter
Copy link
Author

just found this same issue on debian jessie with gcc-avr 4.7.2 / 
arduino-tiny-0100-0016

how is this not fixed in the May 24th 2013 release? i mean even Blink won't 
work without it and its a two year old bug!

the fix that worked for me was commenting out line 137 of 
~/sketchbook/hardware/tiny/cores/tiny/wiring.h

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

but i assume that now means we can't using the round() function....?

Original comment by synaptic...@gmail.com on 3 Jun 2013 at 8:53

@GoogleCodeExporter
Copy link
Author

The round macro has been removed.

Original comment by arduino....@gmail.com on 6 Jun 2013 at 5:14

  • Changed state: Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant