Shop OBEX P1 Docs P2 Docs Learn Events
did I miss a note on floats in printf? — Parallax Forums

did I miss a note on floats in printf?

frank freedmanfrank freedman Posts: 1,983
edited 2011-12-11 17:36 in Propeller 1
I got an error on a simple piece of test code. Wondering if I missed something in the release notes...

no float in printf: link with -lm rounded == 0

the code is as copied from a book:
 Paste failed, but will edit later...outa time now.......



Frank

Comments

  • ersmithersmith Posts: 6,099
    edited 2011-12-11 15:55
    I got an error on a simple piece of test code. Wondering if I missed something in the release notes...

    no float in printf: link with -lm rounded == 0

    Frank

    In order to avoid linking in the floating point code (which is quite large), the default version of printf does not support floats. To get it, you need to link with the math library. To do this add "-lm" to the end of your final link line, e.g.:
    propeller-elf-gcc -o foo.elf foo.o bar.o baz.o -lm
    
    If you're not actually linking, but just compiling all the .c files, it's still the same:
    propeller-elf-gcc -o foo.elf foo.c -lm
    

    Eric
  • frank freedmanfrank freedman Posts: 1,983
    edited 2011-12-11 17:36
    Thanks, will try this when I get home.
    F

    Yep, I did miss the memo. Right in the documents.......
    F
Sign In or Register to comment.