delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/14/14:19:28

From: buers AT gmx DOT de (Dieter Buerssner)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: need info
Date: 14 Apr 2000 17:56:27 GMT
Lines: 72
Message-ID: <8d7t9b.3vvqipv.0@buerssner-17104.user.cis.dfn.de>
References: <yzuJ4.2920$4W3 DOT 43382 AT typhoon DOT nyroc DOT rr DOT com> <8d779a$dsq$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <8d7lbn DOT 3vvqipv DOT 0 AT buerssner-17104 DOT user DOT cis DOT dfn DOT de> <38F75B4A DOT 32E4DF7E AT is DOT elta DOT co DOT il>
NNTP-Posting-Host: pec-0-170.tnt1.s2.uunet.de (149.225.0.170)
Mime-Version: 1.0
X-Trace: fu-berlin.de 955734987 7153327 149.225.0.170 (16 [17104])
X-Posting-Agent: Hamster/1.3.13.0
User-Agent: Xnews/03.02.04
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Eli Zaretskii wrote:

>Dieter Buerssner wrote:
>> 
>> Hans-Bernhard Broeker wrote:
>> 
>> >Only 1) is really on-topic in this newsgroup, I think. The answer in a
>> >nutshell could be as simple as 'write them to the stdprn stream'.
>> 
>> Or fopen the printer device in binary mode.
>
>The predefined stream stdprn is already open in binary mode.  See the file
>src/libc/dos/io/dosio.c in the library sources.
>
>> Something like
>> 
>> #define PRINTER_DEVICE "prn:"
>> 
>> FILE *fpprn = fopen(PRINTER_DEVICE, "wb");
>
>This won't work: the DOS device name is "PRN", without the colon.  

Sorry. But I still think, the method is preferable (when done correctly).
Of course PRINTER_DEVICE should be a run-time variable (which is
the method I use normally). 

>> may be easier to port.
>
>Why is it easier to port?  All DOS/Windows environments support stdprn
>because the printer is always open on handle 4 when the program starts.

I didn't think of porting to DOS/Windows only. With the method I 
suggested, you could define PRINTER_DEVICE as a temporary file,
and the program would at least work, without much trouble.

>> Also, the availability of stdprn in DJGPP
>> depends on compiler flags. (IIRC, it won't work with -ansi.)
>
>Nope, stdprn is always available.  You can see in stdio.h that its
>declaration is before the "#ifdef __STRICT_ANSI__" part, which begins the
>part that's invisible to the compiler under -ansi.

Then, I must have some weird configuration. It is after
#ifndef __STRICT_ANSI__ in my stdio.h

The following script is with DJGPP 2.03 and gcc 2.95.2

E:\test>cat printer.c

#include <stdio.h>

int main(void)
{
  fprintf(stdprn, "Hello World\n");
  return 0;
}

E:\test>gcc -Wall -ansi printer.c

printer.c: In function `main':
printer.c:5: `stdprn' undeclared (first use in this function)
printer.c:5: (Each undeclared identifier is reported only once
printer.c:5: for each function it appears in.)

E:\test>gcc -Wall printer.c


E:\test>exit


-- 
Regards, Dieter

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019