This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of CD1 status.

### 805. `posix_error::posix_errno` concerns

Section: 19.5 [syserr] Status: CD1 Submitter: Jens Maurer Opened: 2008-02-24 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [syserr].

View all issues with CD1 status.

Discussion:

19.5 [syserr]

>     namespace posix_error {
>       enum posix_errno {
>         address_family_not_supported, // EAFNOSUPPORT
>         ...

should rather use the new scoped-enum facility (9.7.1 [dcl.enum]), which would avoid the necessity for a new `posix_error` namespace, if I understand correctly.

[ Further discussion: ]

> See N2347, Strongly Typed Enums, since renamed Scoped Enums.

> Alberto Ganesh Barbati also raised this issue in private email, and also proposed the scoped-enum solution.

> Nick Stoughton asked in Bellevue that `posix_error` and `posix_errno` not be used as names. The LWG agreed.

> The wording for the Proposed resolution was provided by Beman Dawes.

Proposed resolution:

Change System error support 19.5 [syserr] as indicated:

>     namespace posix_error {
>       enum posix_errno class errc {
>         address_family_not_supported, // EAFNOSUPPORT
>         ...
>         wrong_protocol_type, // EPROTOTYPE
>       };
>     } // namespace posix_error

>     template <> struct is_error_condition_enum<posix_error::posix_errno errc>
>       : public true_type {}

>     namespace posix_error {
>       error_code make_error_code(posix_errno errc e);
>       error_condition make_error_condition(posix_errno errc e);
>     } // namespace posix_error

Change System error support 19.5 [syserr] :

> The `is_error_code_enum` and `is_error_condition_enum` templates may be specialized for user-defined types to indicate that such a type is eligible for class `error_code` and class `error_condition` automatic conversions, respectively.

Change System error support 19.5 [syserr] and its subsections:

> - remove all occurrences of `posix_error::`
> - change all instances of `posix_errno` to `errc`
> - change all instances of `posix_category` to `generic_category`
> - change all instances of `get_posix_category` to `get_generic_category`

Change Error category objects 19.5.3.5 [syserr.errcat.objects], paragraph 2:

> Remarks: The object's `default_error_condition` and equivalent virtual functions shall behave as specified for the class `error_category`. The object's name virtual function shall return a pointer to the string "POSIX" "generic".

Change 19.5.4.5 [syserr.errcode.nonmembers] Class `error_code` non-member functions as indicated:

>     error_code make_error_code(posix_errno errc e);

> > Returns: `error_code(static_cast<int>(e), posixgeneric_category)`.

Change 19.5.5.5 [syserr.errcondition.nonmembers] Class `error_condition` non-member functions as indicated:

>     error_condition make_error_condition(posix_errno errc e);

> > Returns: `error_condition(static_cast<int>(e), posixgeneric_category)`.

Rationale:

Names Considered
`portable` | Too non-specific. Did not wish to reserve such a common word in namespace std. Not quite the right meaning, either.
`portable_error` | Too long. Explicit qualification is always required for scoped enums, so a short name is desirable. Not quite the right meaning, either. May be misleading because `*_error` in the std lib is usually an exception class name.
`std_error` | Fairly short, yet explicit. But in fully qualified names like `std::std_error::not_enough_memory`, the std_ would be unfortunate. Not quite the right meaning, either. May be misleading because `*_error` in the std lib is usually an exception class name.
`generic` | Short enough. The category could be `generic_category`. Fully qualified names like `std::generic::not_enough_memory` read well. Reserving in namespace std seems dicey.
`generic_error` | Longish. The category could be `generic_category`. Fully qualified names like `std::generic_error::not_enough_memory` read well. Misleading because `*_error` in the std lib is usually an exception class name.
`generic_err` | A bit less longish. The category could be `generic_category`. Fully qualified names like `std::generic_err::not_enough_memory` read well.
`gen_err` | Shorter still. The category could be `generic_category`. Fully qualified names like `std::gen_err::not_enough_memory` read well.
`generr` | Shorter still. The category could be `generic_category`. Fully qualified names like `std::generr::not_enough_memory` read well.
`error` | Shorter still. The category could be `generic_category`. Fully qualified names like `std::error::not_enough_memory` read well. Do we want to use this general a name?
`err` | Shorter still. The category could be `generic_category`. Fully qualified names like `std::err::not_enough_memory` read well. Although alone it looks odd as a name, given the existing `errno` and `namespace std` names, it seems fairly intuitive. Problem: `err` is used throughout the standard library as an argument name and in examples as a variable name; it seems too confusing to add yet another use of the name.
`errc` | Short enough. The "c" stands for "constant". The category could be `generic_category`. Fully qualified names like `std::errc::not_enough_memory` read well. Although alone it looks odd as a name, given the existing `errno` and `namespace std` names, it seems fairly intuitive. There are no uses of `errc` in the current C++ standard.