This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

/dev/null on Windows [was: Re: gcc.dg/compat/struct-layout-1.exp ....]


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]