Mail Archives: djgpp/2000/04/14/14:19:28
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 -