On Fri, 2012-06-08 at 16:54 +0800, Bin.Cheng wrote:
> Hi all,
> In micro-controller applications, code size is critical and the size
> problem is worse if library is linked.
> For example, most c programs call printf to format output data, that
> means floating point code get linked even the program only want to
> output non-floating point numbers. Currently, we rely on end-user to
> call iprintf if the program does not want floating point.
> 
> I noticed that GCC now can check format string of printf functions, so
> I am wondering if it is possible to take advantage of this utility, by
> making gcc detect whether printf prints floating point number and then
> generate assembly directive in backend to pull in floating point
> functions only if necessary.
> 
> The problem is:
> The check is done in front end, so how should I expose the check
> result to back-end. Is there any hook utility?
> 
> In the future, could this feature be supported by GCC in upstream? I
> assuming mcu backends may have interests in this.
> 

Wouldn't it be much simpler and easier to just provide a customized
printf implementation in the C runtime/std lib which does not use
floating point types or simply prints a hex number when doing a '%f' or
something like that?

Another idea could be to try using a variadic template printf, if you
can get the C code to compile as C++ :)

Cheers,
Oleg

Reply via email to