I do not know about C ...
... but in C ++ the idea is not to use error codes at all.
I do not mean that you should use exceptions, but the error code is not very informative (there is no context, what FILE_NOT_FOUND cost when the file name is unknown?).
In those cases where I did not use exceptions, I preferred objects with a complete error. An example would be:
boost::variant<File, Error> open(std::string const& filename, FileMode mode);
where you get either a file or an error, depending on what happens.
Matthieu M.
source share