From: linnix on
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
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
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
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
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)
 |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10
Prev: ATI Catalyst 10.3 Preview Edition
Next: Network fabric