Hi,

> For example this works:
> printf("%s", "Hello");
> But this doesn't:
> printf("%d", 7);
> 
> In some case the program seems to hang, other times I only get garbage.

printf (varargs in general) are pretty easily confused by type mismatches:
Passing a 2-byte int via stack where a 1-byte char is expected can easily
break printf's output, though the remainder should remain unaffected (unless
some vararg pointer is used to write to memory, in which case a size mismatch
in any of the preceeding arguments will cause... say "interesting" results :-(

Printf has been reported to work fine; I have been using it myself successfully.
* You may try to use

PUTCHAR(char c)
{
  /* output c somehow */
}

volatile int i;
i=7;
stdout=STREAM_USER;
printf("%s", i);

to make sure that a two-byte int is passed to printf.
* Also make sure you have selected a proper stdout: AFAIK, stdout is left 
undefined
by default, which causes an undefined putchar routine to be used.
* You might also need to define a proper putchar routine (using the PUTCHAR 
prototype macro,
see device/pic16/stdio.h) for use with STREAM_USER.

> Of course I can do this conversion by hand. But I want to check out  
> the functions in the library. Am I doing something wrong? Is there a  
> way to make this work?

Please try the hints above or report more detailed what you already did;
how you want to output your chars;
whether you defined PUTCHAR or not;
any other possibly helpful info ;-)

Regards,
Raphael

_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to