sam@kalessin.jpl.nasa.gov (Sam Sirlin) (06/18/91)
I'm trying to port a compiler (apl2c) written in C to msdos using dj delorie's gcc (1.01 currently). The compiler has several stages that pass intermediate results using stdout, stdin. The problem is that the data passed ought to be binary rather than dos text. It appears to me that stdin (e.g. putchar, getchar etc.) only write/read dos text. If I use a file, I can toggle between the two using either the "b" option or setting _fmode (not _ftype as in the docs), but this doesn't seem to work for stdin/stdout. Is this true? Do I have to rewrite the io to use files or make it into printable text? Sam Sirlin Jet Propulsion Laboratory sam@kalessin.jpl.nasa.gov
dj@ctron.com (DJ Delorie) (06/18/91)
In article <1991Jun18.045843.24870@jato.jpl.nasa.gov>, sam@kalessin.jpl.nasa.gov (Sam Sirlin) writes: > pass intermediate results using stdout, stdin. The problem is that the > data passed ought to be binary rather than dos text. It appears to me > that stdin (e.g. putchar, getchar etc.) only write/read dos text. If I Hmmm... I seem to recall adding a "setmode" function that operates similarly to Turbo's, but I don't recall if it is supposed to work with stdio streams. You've got the sources - check it out and fix it if it doesn't (or add the apropriate function). I'll check out the documentation and my sources as well. setmode() on a FILE*'s file number should be enough for stdout/stdin, as long as you don't do ftell() on it, which (I believe) is the only function that uses the flags set in the FILE structure (you can always reset the flag by hand - see stdio.h) DJ dj@ctron.com