<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Reducing printf sprintf scanf footprint does not work as expected in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reducing-printf-sprintf-scanf-footprint-does-not-work-as/m-p/133683#M1449</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;There are 3 versions of every library delivered. One without floating point, one with "just" IEEE32 and one with IEEE64.&lt;BR /&gt;If you link against the library without floating point, then you already have a printf without the floating point support, could that be the reason for the behavior you observe?&lt;BR /&gt;The FAQ may still be useful for other purposes, like if your application does use floating point for other operations and not for sprintf. Or if your application does not need the long or octal support sprintf provides.&lt;BR /&gt;&lt;BR /&gt;Also note that #define &lt;B&gt;__NO_FLOAT__ 1 can also be done via -D&lt;/B&gt;&lt;B&gt;__NO_FLOAT__=1 compiler command line option. I think wizard generated projects where no floating point support&amp;nbsp; was chosen have this option (not 100% sure).&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;&lt;/B&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by CompilerGuru on &lt;SPAN class="date_text"&gt;2007-05-13&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;10:23 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 May 2007 03:22:57 GMT</pubDate>
    <dc:creator>CompilerGuru</dc:creator>
    <dc:date>2007-05-14T03:22:57Z</dc:date>
    <item>
      <title>Reducing printf sprintf scanf footprint does not work as expected</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reducing-printf-sprintf-scanf-footprint-does-not-work-as/m-p/133682#M1448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;SPAN&gt;A Metrowerks FAQ document explains the way to dramatically reduce code generated by the use of printf / scanf functions. This is an usual procedure in most good compilers. In my case I am not using floats. The document indicates the following steps that I have implemented in my 5.1 version for the HC08:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;****************&lt;/SPAN&gt;&lt;BR /&gt;&lt;I&gt;FAQ Libraries:&lt;BR /&gt;&lt;BR /&gt;Q Footprint from function “printf” is too big. How can I reduce the code size for this function?&lt;BR /&gt;A In fact according to the ANSI C standard, the function printf must support a lot of different formats.&lt;BR /&gt;&lt;BR /&gt;This is the main reason why this function takes so much memory.&lt;BR /&gt;As we know that the amount of memory is limited on an embedded processor, there is a way to&lt;BR /&gt;minimize the footprint for the function printf.&lt;BR /&gt;&lt;BR /&gt;?? Add the file &lt;STRONG&gt;printf.c located in your LIB\HC08c\src&lt;/STRONG&gt; installation directory to your project.&lt;BR /&gt;?? In the "Link Order" view &lt;STRONG&gt;make sure the file printf.c comes before the file ansi.lib&lt;/STRONG&gt;. Use drag and&lt;BR /&gt;drop to bring the file ansi.lib at the end of the list for example.&lt;BR /&gt;?? &lt;STRONG&gt;Edit the file "libdefs.h"&lt;/STRONG&gt; located in your LIB\HC08c\include installation directory.&lt;BR /&gt;?? In this file, there is a couple of macros, which can be modified to minimize the amount of code&lt;BR /&gt;in the function vprintf. The macros are defined around line 180.&lt;BR /&gt;For instance setting &lt;STRONG&gt;LIBDEF_PRINTF_FLOATING to 0 will reduce the code drastically&lt;/STRONG&gt;. Be&lt;BR /&gt;careful, with this modification the customer will not be able to format floating point values&lt;BR /&gt;(float, double) any more.&lt;BR /&gt;Usage of each macro is explained in the header file. So you should be able to adjust the&lt;BR /&gt;function vprintf to your own needs.&lt;BR /&gt;?? Now build the application.&lt;/I&gt;&lt;BR /&gt;&lt;SPAN&gt;****************&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Followed the instructions strictly, removed all of the object code and recompiling, there is no change in the ouput file size. The file is very explicit about the effects when editing. I have just included the following line at the top of the libdefs.h file:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;#define __NO_FLOAT__ 1&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any idea of how to make it work will be very much appreciated. Thank you !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BooleanBob&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2007 00:35:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reducing-printf-sprintf-scanf-footprint-does-not-work-as/m-p/133682#M1448</guid>
      <dc:creator>BooleanBob</dc:creator>
      <dc:date>2007-05-14T00:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reducing printf sprintf scanf footprint does not work as expected</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reducing-printf-sprintf-scanf-footprint-does-not-work-as/m-p/133683#M1449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;There are 3 versions of every library delivered. One without floating point, one with "just" IEEE32 and one with IEEE64.&lt;BR /&gt;If you link against the library without floating point, then you already have a printf without the floating point support, could that be the reason for the behavior you observe?&lt;BR /&gt;The FAQ may still be useful for other purposes, like if your application does use floating point for other operations and not for sprintf. Or if your application does not need the long or octal support sprintf provides.&lt;BR /&gt;&lt;BR /&gt;Also note that #define &lt;B&gt;__NO_FLOAT__ 1 can also be done via -D&lt;/B&gt;&lt;B&gt;__NO_FLOAT__=1 compiler command line option. I think wizard generated projects where no floating point support&amp;nbsp; was chosen have this option (not 100% sure).&lt;BR /&gt;&lt;BR /&gt;Daniel&lt;BR /&gt;&lt;BR /&gt;&lt;/B&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by CompilerGuru on &lt;SPAN class="date_text"&gt;2007-05-13&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;10:23 PM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 May 2007 03:22:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Reducing-printf-sprintf-scanf-footprint-does-not-work-as/m-p/133683#M1449</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2007-05-14T03:22:57Z</dc:date>
    </item>
  </channel>
</rss>

