This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
/dev/null on Windows [was: Re: gcc.dg/compat/struct-layout-1.exp ....]
- From: Danny Smith <danny_smith_0000 at yahoo dot co dot nz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: mark at codesourcery dot com
- Date: Wed, 18 May 2005 09:10:02 +1200 (NZST)
- Subject: /dev/null on Windows [was: Re: gcc.dg/compat/struct-layout-1.exp ....]
- Reply-to: dannysmith at users dot sourceforge dot net
Mark Mtchell wrote:
http://gcc.gnu.org/ml/gcc/2005-05/msg00844.html
> (There's still a POSIX-ism in the generator, in that it tries to write
> to "/dev/null". On Windows systems, I bet this will often work, but
> create a real file with that name. It would be better, and avoid
> portability problems, to guard the calls to fwrite, etc., with "if
> (file)" rather than spew to "/dev/null", but that's for another day.)
Attempt to write to /dev/null on Windows fails. The HOST_BIT_BUCKET on
Windows is the reserved filename "nul" (with any extension, eg "nul.c"
or "nul.C" are both equivalen to "nul").
#include <stdio.h>
int main ()
{
FILE* outfile = fopen ("/dev/null", "w");
if (outfile == NULL)
{
fputs ("could not open '/dev/null'", stderr);
}
outfile = fopen ("nul", "w");
if (outfile == NULL)
{
fputs ("could not open 'nul'", stderr);
}
return 0;
}
prints "could not open '/dev/null'" on stderr.
No files are created.
Danny
Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com