4 ms·
yes, the syntax is not great, but it is not really worse than errno. Especially because you can initialize the error object at declaration point and, as you poi
by gpderetta 8y ago
yes, the syntax is not great, but it is not really worse than errno. Especially because you can initialize the error object at declaration point and, as you pointed out, you would otherwise need to zero errno:
struct error res = library_function(arg);
if (res.result)
{
// use res.errno
...
}
Also remember the whole thread is about improving the syntax for this sort of stuff. C could take (another) page from C++:
auto [result, errno] = library_function(arg);
if (result == -1)
{
// use errno ...
}