From: "Beman Dawes" <[EMAIL PROTECTED]> > At 08:19 AM 12/13/2002, Peter Dimov wrote: > > >From: "Beman Dawes" <[EMAIL PROTECTED]> > >> > >> Part of the problem is that there is no guarantee that the macros will > be > >> available in <cerrno>. > > > >Yes, that's true in theory, but in practice, is there a platform that > >doesn't have the macros in <cerrno>? > > It is messier than that. For example, Microsoft supplies cerrno with only > some of the macros. EBUSY, ENOTDIR, ENOTEMPTY, and others are missing.
I see EBUSY (16), ENOTDIR (20), ENOTEMPTY (41) in errno.h in both VC6 and VC7(.1). > The filesystem library also needs one or two additional codes for its own > errors. This is an interesting problem; we'll have to get back to it. :-) > >Note that there are two issues here. First, whether the portable error > code > >reported by the library matches the numeric value of the corresponding > EXXX > >macro. Second, how does the exception.hpp header make the constants > >available, i.e. does it #include <cerrno> (with <cerrno> guaranteed to > have > >the macros), or does it provide its own aliases. > > The "already standard" argument you make below pushes toward including > <cerrno>. Yet usual C++ practice would be more like the enum in the current > header, and not including <cerrno>. The question for me is not whether exception.hpp includes <cerrno>, but whether it defines the E... macros. An enum in the current header is good enough, although providing two different naming schemes for the same error codes must be justified by more than "we don't like <cerrno>". > Would you see any value in providing aliases with names that map more > closely to the POSIX names? > > For example, instead of: > > not_found_error, > not_directory_error, > > Would you prefer: > > enoent, > enotdir, > > If so, why? You haven't addressed an important question, is not_found_error/enoent equal to ENOENT? If it is, enoent obviously wins over not_found_error as otherwise people need to maintain a mental map. In a perfect world users will never leave the filesystem sandbox so this doesn't really matter; but this is rarely the case in real code that typically needs to go outside the C++ standard in order to do something useful. > I'm wondering if part of your worries could be caused by the lack of a > filesystem function similar to POSIX perror()? No. I have expressed my stance on functions that return implementation-defined strings in the past. ;-) BTW, aren't perror/strerror standard C and hence C++? My preferred approach to obtain a human-readable error message is to get "ENOENT" returned from exception::what(); I know what to do with it (see attachment). But this is a side issue. > > We already have a standard portable > error > >scheme. Why reinvent the wheel? Will we do any better? > > We might. The POSIX errno scheme doesn't seem all that strong to me. > > Your arguments are all reasonable, but I'm still not seeing beyond the > disadvantages of trying to interpret the POSIX approach in C++. Do you have > a firm proposal? But we don't need to interpret anything. POSIX has already done the work for us. :-) My proposal is - portable error codes returned by the filesystem library shall have the same meaning as the corresponding E*** macro, if one exists. In particular, std::strerror(), or an equivalent (the user may already have a fully localized replacement) should produce the right error message. - exception.hpp shall make the E*** macros available (whether it does so by including <cerrno> is unspecified.) (alternatively, it might offer another naming scheme, although I don't see the point in that.) Note that the second bullet can be rejected independently of the first.
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <stream version="3"> <q size="38" name="errno"> <r name="[0]"> <f name="key">E2BIG</f> <f name="value">Arg list too long</f> </r> <r name="[1]"> <f name="key">EACCES</f> <f name="value">Permission denied</f> </r> <r name="[2]"> <f name="key">EAGAIN</f> <f name="value">Resource temporarily unavailable</f> </r> <r name="[3]"> <f name="key">EBADF</f> <f name="value">Bad file descriptor</f> </r> <r name="[4]"> <f name="key">EBUSY</f> <f name="value">Resource device</f> </r> <r name="[5]"> <f name="key">ECHILD</f> <f name="value">No child processes</f> </r> <r name="[6]"> <f name="key">EDEADLK</f> <f name="value">Resource deadlock avoided</f> </r> <r name="[7]"> <f name="key">EDOM</f> <f name="value">Domain error</f> </r> <r name="[8]"> <f name="key">EEXIST</f> <f name="value">File exists</f> </r> <r name="[9]"> <f name="key">EFAULT</f> <f name="value">Bad address</f> </r> <r name="[10]"> <f name="key">EFBIG</f> <f name="value">File too large</f> </r> <r name="[11]"> <f name="key">EILSEQ</f> <f name="value">Illegal byte sequence</f> </r> <r name="[12]"> <f name="key">EINTR</f> <f name="value">Interrupted function call</f> </r> <r name="[13]"> <f name="key">EINVAL</f> <f name="value">Invalid argument</f> </r> <r name="[14]"> <f name="key">EIO</f> <f name="value">Input/output error</f> </r> <r name="[15]"> <f name="key">EISDIR</f> <f name="value">Is a directory</f> </r> <r name="[16]"> <f name="key">EMFILE</f> <f name="value">Too many open files</f> </r> <r name="[17]"> <f name="key">EMLINK</f> <f name="value">Too many links</f> </r> <r name="[18]"> <f name="key">ENAMETOOLONG</f> <f name="value">Filename too long</f> </r> <r name="[19]"> <f name="key">ENFILE</f> <f name="value">Too many open files in system</f> </r> <r name="[20]"> <f name="key">ENODEV</f> <f name="value">No such device</f> </r> <r name="[21]"> <f name="key">ENOENT</f> <f name="value">No such file or directory</f> </r> <r name="[22]"> <f name="key">ENOEXEC</f> <f name="value">Exec format error</f> </r> <r name="[23]"> <f name="key">ENOLCK</f> <f name="value">No locks available</f> </r> <r name="[24]"> <f name="key">ENOMEM</f> <f name="value">Not enough space</f> </r> <r name="[25]"> <f name="key">ENOSPC</f> <f name="value">No space left on device</f> </r> <r name="[26]"> <f name="key">ENOSYS</f> <f name="value">Function not implemented</f> </r> <r name="[27]"> <f name="key">ENOTDIR</f> <f name="value">Not a directory</f> </r> <r name="[28]"> <f name="key">ENOTEMPTY</f> <f name="value">Directory not empty</f> </r> <r name="[29]"> <f name="key">ENOTTY</f> <f name="value">Inappropriate I/O control operation</f> </r> <r name="[30]"> <f name="key">ENXIO</f> <f name="value">No such device or address</f> </r> <r name="[31]"> <f name="key">EPERM</f> <f name="value">Operation not permitted</f> </r> <r name="[32]"> <f name="key">EPIPE</f> <f name="value">Broken pipe</f> </r> <r name="[33]"> <f name="key">ERANGE</f> <f name="value">Result too large</f> </r> <r name="[34]"> <f name="key">EROFS</f> <f name="value">Read-only file system</f> </r> <r name="[35]"> <f name="key">ESPIPE</f> <f name="value">Invalid seek</f> </r> <r name="[36]"> <f name="key">ESRCH</f> <f name="value">No such process</f> </r> <r name="[37]"> <f name="key">EXDEV</f> <f name="value">Improper link</f> </r> </q> </stream>
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost