During the process of compilation of my C++ program on Linux, it gives the following warning:
warning #584: omission of exception specification is incompatible with previous function "__errno_location" (declared at line 43 of "/usr/include/bits/errno.h")
extern int errno;//error handling
^
The code is shown below:
#include <errno.h> //for error handling
#include <cmath>
#include <cstring>
#include <ctime>
extern int errno;//error handling
errno
is a global variables, it is used in other .cpp
files. How can I solve this?
errno
is required to be a "modifiable lvalue", not necessarily a declared object.
Apparently on your implementation, errno
expands to an expression that includes a call to a function called __errno_location
.
In your own declaration:
extern int errno;
errno
expands to that expression, resulting in an error.
Since <errno.h>
already declared errno
for you, there's no need to declare it yourself, and as you've seen, you can't declare it yourself.
Just omit that extern
declaration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With