Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24



On Sunday, in article
<j6d4l1d04mj3ctm28lqqacr5sgo2slj55i@xxxxxxx> keinanen@xxxxxx
"Paul Keinanen" wrote:

>On Sun, 16 Oct 2005 02:24:21 +0100 (BST),
>paul$@pcserviceselectronics.co.uk (Paul Carpenter) wrote:
>
>>Creating a custom printf is MUCH better than using a library function
>>many applications do not need
>>
>> Floats
>> scientific of exponential notation
>> pointer printing
>> long modifiers
>> escape characters (form feed, line feed, bell)
>>
>>Mnay only need single character or formatted strings with a byte or short
>>(signed/unsigned printing).

Forgot the one that is RARELY needed in embedded situations, and relying on
it, would mean a bad design anyway - printf returns the number of
characters output which I have not *yet* seen an application use.

>If the library sources are available, it should be easy to disable the
>floats etc.
>
>However, if the library sources are not available, but if the library
>object files have been divided intelligently, e.g. the actual printf
>function in printf.obj and the floating point printing routines in
>print_float.obj, it should be possible to create dummy_float.c
>containing e.g.
>
>void print_float (double d.....)
>{
> return ;
>}

Makes a lot of assumptions, works on one library, for better code reuse
for MINIMAL footprints, use a stripped down one for usability on more
compilers and targets.

>Put the dummy_float.obj on the linker command line _before_ the
>library files. When the linker detects the printf reference in he
>application program, it extracts the printf.obj from the library.
>Since that printf module contains a reference to print_float, the
>linker already knows where it is, since it has been provided by the
>dummy_float.obj and does not need to retrieve the print_float.obj from
>the library.

Assuming the library module for that function, is actually a separate
module whereby you can save space, otherwise you will have it *POTENTIALLY*
included but not used.

That solution is very compiler/linker/library dependant.

--
Paul Carpenter | paul@xxxxxxxxxxxxxxxxxxxxxxxxxxx
<http://www.pcserviceselectronics.co.uk/> PC Services
<http://www.gnuh8.org.uk/> GNU H8 & mailing list info
<http://www.badweb.org.uk/> For those web sites you hate

.



Relevant Pages

  • Re: Include statements and compiler linking
    ... Why is it that the header file doesnt need to be linked ... linker not knowing the PATH to the header file. ... -there is function (e.g printf), ... You tell the compiler how to use the code ...
    (comp.lang.c)
  • Re: bug raport - about way of linking in c
    ... and d has a "printf" definition too (same signature ... But when one will try to link it linker ... be a source-level solution such as name spaces. ... Linker should not just fail but should just calmly ...
    (comp.lang.c)
  • Re: bug raport - about way of linking in c
    ... and d has a "printf" definition too (same signature ... On compiler level it is no problem, ... But when one will try to link it linker ... linker will fail because it will be trying to ...
    (comp.lang.c)
  • Re: Microchip Introduces First 16-bit Microcontroller Product Line - the PIC24
    ... >Creating a custom printf is MUCH better than using a library function ... Put the dummy_float.obj on the linker command line _before_ the ... When the linker detects the printf reference in he ...
    (comp.arch.embedded)
  • Re: program having printf() function invocation without including
    ... warning and would assume that it would return a int, ... make your call to printf() to a printfroutine in a library. ... There are some implementations on which the linker does ... reason a C compiler could not do the same thing, ...
    (comp.lang.c)