M
Melzzzzz
In C code that I have seen the functions return an int. Sometimes there
is enum returned. One value (often 0) indicates success and rest of the
values mean error codes. It is unlikely that whole string buffer and its
size as parameters will be devoted to error handling in real code.
Well, depending on scenario, sometimes message cannot be known
at top level. That's why I like exceptions more.
You get error message in object instead to propagate buffer.
Lot of C++ coding standards require throwing application-specific
exceptions. Such may be inherited from std::exception family but note
that in memory-constrained situation the bad_alloc will fly here instead
of runtime_error.
On Linux, (at least by default setup) one would never see bad_alloc,
because of overcommit.
If you want to improve performance of exception objects then you can
throw pointers to static exception objects or throw your own exception
objects that do not manage memory dynamically or derive such from
std::exception by overriding what() instead of having string constructor
arguments.
I don't have problems with strings and exception objects at all.
Actually c++ is very efficient so that one can relax when writing
code and code will work at acceptable performance.
In my early c++ days I used to optimise everything (computers were with
low memory and slow), now I really don't care, since programs just work.
Perhaps in some other language I would worry about performance
but not in c++.