/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / How do you use small printf lib in a user library

Username:     
Password:     
             

Forum
  • Index
  •  » circleOS
  •  » How do you use small printf lib in a user library

# 1   2012-01-20 15:24:03 How do you use small printf lib in a user library

johnja9
New member
Registered: 2011-05-13
Posts: 6

How do you use small printf lib in a user library

There is a 'use small printf' compiler option available when you build single-file applications, but this doesn't appear to be available when build a library.

Can anyone explain how to include the small printf library in a user library?

Thanks

John

Offline

 

# 2   2012-01-24 17:48:41 How do you use small printf lib in a user library

Bruno
Software Engineer
From: Montbonnot, France
Registered: 2007-07-11
Posts: 13
Website

Re: How do you use small printf lib in a user library

Hi,

Please refer to http://forum.raisonance.com/viewtopic.php?id=4414

Best Regards.


-- Bruno Richard, Ph.D.

Offline

 

# 3   2012-02-22 04:56:42 How do you use small printf lib in a user library

johnmathew
New member
Registered: 2012-02-21
Posts: 1

Re: How do you use small printf lib in a user library

The library actually implements functions tfp_printf and tfp_sprintf and declared two macros, printf and sprintf, that expand to the names of the library functions. Now, I know, this sort of non function style macro usage, especially with lower case names, can be evil. A better/cleaner solution would have been the use of variadic macros but for reasons lost in the dusk of history I did not. Feel free to modify either the macros or the function names.

To conserve space the library does not support printing long ints unless you define the macro PRINTF_LONG_SUPPORT. To support long the compiler will pull the 32 bit math libraries (assuming long is 32 bits here) and this will greatly increase the memory footprint. When debugging, especially when bringing up a board, space can be at premium, yet, if you are working with a 16/32 bit processor you may need to print 32 bit hex values. You can do that, without enablind the long support as follows:

long v=0xDEADBEEF;
printf("v=%04X%04X\n", v >> 16, v & 0xffff); // actually the '& 0xffff' is propably superfluous if int is 16 bits
This should output:
v=DEADBEEF

Offline

 

  • Index
  •  » circleOS
  •  » How do you use small printf lib in a user library

Board footer