13 Replies Latest reply on Nov 16, 2018 12:46 AM by alexdobrikov_3787101

    How to use sprintf() with float

    alexdobrikov_3787101

      Hello!

       

      I can't solve the problem with using float in family of printf() functions in my C project.

      I use EZ-USB SDK 1.3 with SUPERSPEED EXPLORER KIT.

       

      I want to use sprintf() and vsprintf() (with va_list) for creating debug messages.

      But when i add printf() family functions into my project, I receive linker error (picture 1):

      1_page.png

      Picture 1

      I read in different forums, that for using float int printf() there are two ways:

       

      1. Add to my project cyfxcppsyscall.cpp file (with _sbrk definition) and #include <sys/unistd.h> file, where using sprintf().

      Also add __heap_start and __heap_end definition in fx3.ld linker file.

       

      It's not work - i also see undefined reference to '_sbrk'

       

      2. Add linker flags: -specs=nosys.specs -specs=nano.specs -u _printf_float

       

      See page:

       

      2_page.png

      In second