Prev: NET tips to expand your biz
Next: IR is insane
From: linnix on 18 Mar 2010 13:47 In response to another thread, I am still getting these problems with WinAVR 2010. I think the linker is hitting some AVR limits. There are similar reports on the web as well. ------------------------------------------------------------------------------------------------- unsigned char u; float f; u = (unsigned char) f; --------------------------------------------------------------------------------------------------- c:/wavr10/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/ avr35\libc.a(fp_powsodd.o): In function `__fp_powsodd': (.text.avr-libc.fplib+0x10): relocation truncated to fit: R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in c:/wavr10/bin/../lib/gcc/avr/4.3.3/avr35\libgcc.a(_mul_sf.o) c:/wavr10/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/ avr35\libc.a(fp_powsodd.o): In function `__fp_powsodd': (.text.avr-libc.fplib+0x20): relocation truncated to fit: R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in c:/wavr10/bin/../lib/gcc/avr/4.3.3/avr35\libgcc.a(_mul_sf.o)
From: Tim Wescott on 18 Mar 2010 14:24 linnix wrote: > In response to another thread, I am still getting these problems with > WinAVR 2010. I think the linker is hitting some AVR limits. There > are similar reports on the web as well. > ------------------------------------------------------------------------------------------------- > > unsigned char u; > float f; > > u = (unsigned char) f; > > --------------------------------------------------------------------------------------------------- > c:/wavr10/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/ > avr35\libc.a(fp_powsodd.o): In function `__fp_powsodd': > (.text.avr-libc.fplib+0x10): relocation truncated to fit: > R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in > c:/wavr10/bin/../lib/gcc/avr/4.3.3/avr35\libgcc.a(_mul_sf.o) > c:/wavr10/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/ > avr35\libc.a(fp_powsodd.o): In function `__fp_powsodd': > (.text.avr-libc.fplib+0x20): relocation truncated to fit: > R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in > c:/wavr10/bin/../lib/gcc/avr/4.3.3/avr35\libgcc.a(_mul_sf.o) "relocation truncated to fit" sure sounds ominous. Altavista-ing that phrase pops up with a discussion on an Intel board of 32-bit vs. 64-bit immediate addressing, and the comment "If you're seeing this and you're not hand-coding, you probably want to check out the -mmodel argument to gcc." So it appears that it's not really doing anything serious other than completely screwing up your addressing. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
From: Habib Bouaziz-Viallet on 18 Mar 2010 15:21 Le Thu, 18 Mar 2010 10:47:44 -0700, linnix a écrit : > unsigned char u; > float f; > > u = (unsigned char) f; In what kind of situation you need to cast a float to that unsigned char ??? If you want to extract the integer part of the float, let me tell you that this way is a bit silly. Question yourself before asking to C. Habib
From: linnix on 18 Mar 2010 15:39 On Mar 18, 11:21 am, Habib Bouaziz-Viallet <h.bouazizvial...(a)free.fr> wrote: > Le Thu, 18 Mar 2010 10:47:44 -0700, linnix a écrit : > > > unsigned char u; > > float f; > > > u = (unsigned char) f; > > In what kind of situation you need to cast a float to that unsigned > char ??? > If you want to extract the integer part of the float, let me tell you > that this way is a bit silly. > > Question yourself before asking to C. > > Habib f is result of k1 * sine x + k2 * cosine y. How would you extract the integer part without casting? I thought that's the job of the compiler.
From: D Yuniskis on 18 Mar 2010 16:05
linnix wrote: > In response to another thread, I am still getting these problems with > WinAVR 2010. I think the linker is hitting some AVR limits. There > are similar reports on the web as well. > ------------------------------------------------------------------------------------------------- > > unsigned char u; > float f; > > u = (unsigned char) f; Approach it a little at a time: Try casting to a (signed) int first. If that works, then unsigned (assuming your value truly is "non negative"). Finally, shrink it to a char. Sometimes compilers get upset if you do things that it doesn't expect. You might also experiment with real doubles to see if there are any subtle differences. > --------------------------------------------------------------------------------------------------- > c:/wavr10/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/ > avr35\libc.a(fp_powsodd.o): In function `__fp_powsodd': > (.text.avr-libc.fplib+0x10): relocation truncated to fit: > R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in > c:/wavr10/bin/../lib/gcc/avr/4.3.3/avr35\libgcc.a(_mul_sf.o) > c:/wavr10/bin/../lib/gcc/avr/4.3.3/../../../../avr/lib/ > avr35\libc.a(fp_powsodd.o): In function `__fp_powsodd': > (.text.avr-libc.fplib+0x20): relocation truncated to fit: > R_AVR_13_PCREL against symbol `__mulsf3' defined in .text section in > c:/wavr10/bin/../lib/gcc/avr/4.3.3/avr35\libgcc.a(_mul_sf.o) |