Eli Zaretskii wrote: > > Because that would yield warnings when you compile on mingw with "-Wall". > > I compiled with -Wall (using intptr_t) and didn't have any warnings. > Maybe you are using a newer (= more pedantic) version of GCC.
Maybe I misremembered, and it was MSVC which gave the warnings. > > Well, I tested also aux, com, com1, lpt, lpt1, prn, and none of these > > resulted in a successful open() call. Only nul and con could be open()ed, > > and only for nul was the value of _isatty() wrong. Tested on Windows XP > > (with no printer connected). YMMV. > > You don't need to open them, you can use redirection: > > _isatty < nul > prn 2>aux > > I tested this on XP, and I see the value 64 returned by _isatty for > every character device. > > Btw, it also works for me to open them, but I tried `fopen', not > `open'. Hmm, even the redirection does not give these results for me: $ cat foo.c #include <stdio.h> #include <windows.h> #include <io.h> #include <fcntl.h> int main (int argc, char*argv[]) { fprintf (stderr, "%d -> %d\n", 0, isatty (0)); fprintf (stderr, "%d -> %d\n", 1, isatty (1)); return 0; } $ gcc -mno-cygwin -Wall foo.c $ cmd >.\a.exe > nul 0 -> 0 1 -> 64 >.\a.exe > con 0 -> 0 1 -> 64 >.\a.exe > aux The system cannot find the specified file. >.\a.exe > prn The system cannot find the specified file. >.\a.exe > lpt 0 -> 0 1 -> 0 >.\a.exe > lpt0 0 -> 0 1 -> 0 >.\a.exe > com 0 -> 0 1 -> 0 >.\a.exe > com0 0 -> 0 1 -> 0 >.\a.exe > com1 The system cannot find the specified file. Apparently you have a different version of Windows than I have... Bruno