Reputation: 103
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?
Upvotes: 6
Views: 12738
Reputation: 263627
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.
Upvotes: 12