Hi Chris,

I'll think about it.
putchar() seems to be reasonable.
But I cannot get you point about weakref.
'Weak' means that the label can be redefined, but the actuall code will be 
linked anyway. This can be solved by changing libraries order. The first 
occurance of function will be linked.

~d



On Tuesday 01 July 2003 23:59, Chris Liechti wrote:
> Dmitry wrote:
> > void uprintf(void (*func)(char c), const char *fmt,...);
>
> ...
>
> > How about changing func defenition to 'int', like:
> >     int uprintf(int (*func)(char c), const char *fmt,...);
> > So, if func returns zero, printing continues, otherwise abort with error
> > code stated by 'func'.
> > What do you think?
>
> or maybe the oter way round?
>
> printf usualy returns the number of bytes printed, thats also a nice
> feature if you need to do some basic text formating.
>
> putchar should also return an int:
> ---
> RETURNS
>         If successful, `putchar' returns its argument CH.  If an  error
>         intervenes, the result is `EOF'....
> ---
> i think it would make sense to keep up with these definitions.
>
> for the sake of backwards compatibility, you should not change uprintf.
> it would brake old programs that pass a "void" function...
>
> on the other hand its quite nice with IAR. you have a "printf" function.
> it uses "putchar" for the output. the putchar function has to be
> provided by the user. (the printf implementation can be chosen too, a
> small version that only supports %d, %s but the bigger versions have
> support for float and field width etc. 3 different implementations in
> total)
>
> the ANSI C printf also copes with failures:
> ---
> RETURNS
>   `sprintf' and `asprintf' return the  number  of  bytes  in  the  output
>   string,  save  that the concluding `NULL' is not counted.  `printf' and
>   `fprintf' return the number of characters  transmitted.   If  an  error
>   occurs,  `printf' and `fprintf' return `EOF' and `asprintf' returns -1.
>   No error returns occur for `sprintf'.
> ---
>
> i would prefer somthing like that:
> libc provides a medium sized printf (i.e. strings and ints, with field
> width, such that "0x%04x" is supported) that works like to above
> documented. it would use "putchar" for the output.
> and important: it's implemented as weakref. that way we can provide
> alternative printf implementations in a separate lib. such as
> "libfloatprintf", "libsmallprintf" or such that you can easily change
> printf implementation with a linker option ("-l floatprintf" in that
> example)
>
> that would be more portable to other platforms, calls to printf are
> shorter than to uprintf, its more flexible and your "EOF" problem would
> be solved automaticaly... what do you think?
>
> chris
>
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by: Free pre-built ASP.NET sites including
> Data Reports, E-commerce, Portals, and Forums are available now.
> Download today and enter to win an XBOX or Visual Studio .NET.
> http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users

-- 
/*****************************************************************
     ("`-''-/").___..--''"`-._     (\   Dimmy the Wild     UA1ACZ
      `6_ 6  )   `-.  (     ).`-.__.`)  State Polytechnical Univ.
      (_Y_.)'  ._   )  `._ `. ``-..-'   Radio-Physics Departament
    _..`--'_..-_/  /--'_.' ,'           Saint Petersburg,  Russia
   (il),-''  (li),'  ((!.-'             +7 (812) 5403923, 5585314
 *****************************************************************/


Reply via email to