Re: Which standards do the implementation support?
In article <hbf.20061026oh 46_-_@bombur.uio.no >
Hallvard B Furuseth <h.b.furuseth@u sit.uio.nowrote :
Rather than answering the POSIX-specific part of this, I will
note that:
errno = 0;
before calling fopen() is probably a good idea anyway, to protect
against broken implementations that do something like this:
FILE *fopen(const char *restrict path, const char *restrict mode) {
FILE *fp;
fp = __stdio_get_new _fp();
if (fp == NULL)
return NULL; /* without setting errno */
... actually try to open the path, which will set errno ...
}
(where __stdio_get_new _fp() returns NULL without setting errno
in at least some cases).
While I do not know that of any specific POSIX implementations that
are broken in this way, I do know of at least one pre-POSIX
implementation that was.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
In article <hbf.20061026oh 46_-_@bombur.uio.no >
Hallvard B Furuseth <h.b.furuseth@u sit.uio.nowrote :
>A recent thread mentioned that the C standard does not guarantee
>that failed file operations set errno. To see if it did, set
>errno=0 before the file operation and test errno afterwards.
>
>I don't want to clutter my entire program with errno settings,
>so is there a way for a general error reporting routine check
>for _common_ implementations which set errno?
>that failed file operations set errno. To see if it did, set
>errno=0 before the file operation and test errno afterwards.
>
>I don't want to clutter my entire program with errno settings,
>so is there a way for a general error reporting routine check
>for _common_ implementations which set errno?
note that:
errno = 0;
before calling fopen() is probably a good idea anyway, to protect
against broken implementations that do something like this:
FILE *fopen(const char *restrict path, const char *restrict mode) {
FILE *fp;
fp = __stdio_get_new _fp();
if (fp == NULL)
return NULL; /* without setting errno */
... actually try to open the path, which will set errno ...
}
(where __stdio_get_new _fp() returns NULL without setting errno
in at least some cases).
While I do not know that of any specific POSIX implementations that
are broken in this way, I do know of at least one pre-POSIX
implementation that was.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.
Comment