I try to get the image from the camera with v4l, ioctl returns -1. How can I get a description of the error?
2 answers
Error description can be obtained from errno.
#include <errno.h> #include <string.h> ... if (ioctl(...) == -1) { printf("Error: %s", strerror(errno)); }
- oneDrugaaan: D Sorry for offtopic :) - metazet
- one
perror("Error:")
- shorter error detail record in the console - mr NAE
|
It is only good to first save the value of errno in any variable of type int and already use it in further code.
#include <errno.h> #include <string.h> ... if (ioctl(...) == -1) { int n = errno; printf("Error: %s", strerror(n)); }
The thing is that between generating its value by calling ioctl and using it, some more error may occur and its value will change.
- In this case you are wrong, there are no other calls between ioctl and strerror that can change errno - dzhioev
|