Re: [cc65] Linking [s]printf breaks cbm_open?

From: Greg King <greg.king41verizon.net>
Date: 2007-09-20 14:30:38
From "Jakob Haufe"; on Sunday, August 26, 2007; at 04:18 PM -0400:
>
> Ullrich von Bassewitz wrote on Sun, 26 Aug 2007, at 20:05:11 +0200
> in 20070826180511.GB22090@trixie.musoftware.de:
> >
> > On Sun, Aug 26, 2007 at 04:44:51PM +0200, Jakob Haufe wrote:
> > > As soon as printf() is linked to the program, cbm_open() always
> > > returns oserror=2 (file open).  That happens even if printf()
> > > never is executed.
> >
> > You cannot use standard file I/O and CBM file I/O together without
> > problems.  Both need file handles, and there is no way to allocate
> > those handles when using standard file I/O invisible to the user.
>
> Is it possible to access a printer using fopen(), etc.?

CBM computers use secondary addresses (channels) to control printer
features.  fopen() and open() don't let us choose those secondary addresses.
Therefore, we must use cbm_open(), etc. to reach printers.

fopen() calls open().  The CBM library's open() uses logical-file-numbers
that start at 3; they count upward as more files are openned at the same
time.  [printf() talks through write() to stdout; stdout (along with stderr)
is openned automatically -- if write() is linked -- as soon as a program
starts.]

The first two file-numbers aren't touched.  "Hidden knowledge" about the
POSIX I/O in that library says that it can use file numbers up to 34.

So, you can choose numbers 1 and 2,
and numbers 40 [I added a cushion ;-)] and greater.

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu, 20 Sep 2007 08:30:38 -0400

This archive was generated by hypermail 2.1.8 : 2007-09-20 14:48:41 CEST