Re: [cc65] C64: CKOUT followed by printf

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2010-12-04 19:00:03
Hi!

On Fri, Dec 03, 2010 at 12:14:56PM +0100, Oliver Schmidt wrote:
> Hm, isn't printf() supposed to write to the 'standard output' ? And
> isn't the enviroment the program runs in free to decide where that
> standard output should actually go (i.e. a shell redirecting the
> standard output to some file/device) ?

That's not part of the C standard. It may be part of the POSIX specs (not sure
about that). It could be implemented in this way on the CBMs (and very old
libraries had it this way as a side effect of not supporting POSIX I/O), but
that has the disadvantage of requiring special processing for stdin/stdout
inside the library and not being able to redirect stdin/stdout/stderr from
within the program itself.

> Again, I'm no C64 guy so I don't actually know, but... in case
> cbm_k_ckout() could be considered the C64 way to decide where the
> standard output goes then I *WOULD* expect printf() to write to that
> location.

That's a misunderstanding. ckout says "use this logical file and make it the
output channel". This call is always required before outputing stuff to any
logical file. It's the same problem is with the logical file numbers: If you
have several independent modules that don't know of each other, and each one
sets the output channel the way it needs, it doesn't work.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sat Dec 4 19:00:12 2010

This archive was generated by hypermail 2.1.8 : 2010-12-04 19:00:15 CET