E
Eric Sosman
CJ said:Or, if you want both flexibility and
portability, you can do something like this (untested code):
if (... fopen failed ...) {
switch (errno) {
#ifdef EACCES
case EACCES:
/* handle permission error */
break;
#endif
[...]
But if you're not using POSIX, you could define EACCESS etc. as glocal
macros yourself, and then this code could break badly...
Such code is already broken, because Eanything is a
reserved identifier in any file that includes <errno.h>.
See section 7.26.3.
(Well, not "anything," exactly. Any identifier starting
with E and another upper-case letter or starting with E and
a digit is reserved. You can still use identifiers that
begin with E and a lower-case letter or with E and an underscore
or, I guess, with E and a suitable Unicode character, and the
identifier E itself is all right. But EACCESS etc. are reserved,
precisely to avoid the collisions that worry you.)