What is errno in C++?
1 Answer 1. errno.h is part of the C subset of C++. It is used by the C library and contains error codes. If a call to a function fails, the variable "errno" is set correspondingly to the error. It will be of no use if you're using the C++ standard library. In C you have functions that translate errno codes to C-strings.
Can you say If errno?
Yes, you can definitely say things like if (errno == ENOENT) { }, and that is the common and recommended way of doing it. In general, do not use errno to determine that an error has occurred. Check the return value of the function, and if the return value indicates an error, then check errno to see what the error was. (More on this below.)
Is errno a macro or a variable?
Notice also that errno (3) is generally a macro (almost behaving as some variable). The msgrcv (2) man page documents that errno could be one of E2BIG, EACCES , EFAULT ENOMSG, ENOSYS (refer to that man page to get the list of all possible errors).