From: Eric Biggers <ebiggers@xxxxxxxxxx> As per 'man 3 errno': On some ancient systems, <errno.h> was not present or did not declare errno, so that it was necessary to declare errno manually (i.e., extern int errno). **Do not do this**. It long ago ceased to be necessary, and it will cause problems with modern versions of the C library. One of the platforms it causes a problem on is Windows: In file included from fgetversion.c:28: fgetversion.c: In function ‘fgetversion’: fgetversion.c:68:20: warning: ‘_errno’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes] 68 | extern int errno; | ^~~~~ Just remove these obsolete manual declarations of errno. Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx> --- lib/e2p/fgetversion.c | 2 -- lib/e2p/fsetversion.c | 1 - lib/e2p/getversion.c | 1 - lib/e2p/setversion.c | 1 - lib/ss/execute_cmd.c | 2 -- lib/ss/help.c | 2 -- lib/ss/pager.c | 2 -- 7 files changed, 11 deletions(-) diff --git a/lib/e2p/fgetversion.c b/lib/e2p/fgetversion.c index a65e9a5c5..f3a5b4cdf 100644 --- a/lib/e2p/fgetversion.c +++ b/lib/e2p/fgetversion.c @@ -65,8 +65,6 @@ int fgetversion(const char *name, unsigned long *version) rc = syscall(SYS_fsctl, name, EXT2_IOC_GETVERSION, &ver, 0); # endif /* !APPLE_DARWIN */ #else /* ! HAVE_EXT2_IOCTLS */ - extern int errno; - errno = EOPNOTSUPP; #endif /* ! HAVE_EXT2_IOCTLS */ if (rc == 0) diff --git a/lib/e2p/fsetversion.c b/lib/e2p/fsetversion.c index c2e045591..5f844b55e 100644 --- a/lib/e2p/fsetversion.c +++ b/lib/e2p/fsetversion.c @@ -65,7 +65,6 @@ int fsetversion (const char * name, unsigned long version) return syscall(SYS_fsctl, name, EXT2_IOC_SETVERSION, &ver, 0); #endif #else /* ! HAVE_EXT2_IOCTLS */ - extern int errno; errno = EOPNOTSUPP; return -1; #endif /* ! HAVE_EXT2_IOCTLS */ diff --git a/lib/e2p/getversion.c b/lib/e2p/getversion.c index 9f719b4a9..d374a0ea7 100644 --- a/lib/e2p/getversion.c +++ b/lib/e2p/getversion.c @@ -35,7 +35,6 @@ int getversion (int fd, unsigned long * version) *version = ver; return r; #else /* ! HAVE_EXT2_IOCTLS */ - extern int errno; errno = EOPNOTSUPP; return -1; #endif /* ! HAVE_EXT2_IOCTLS */ diff --git a/lib/e2p/setversion.c b/lib/e2p/setversion.c index 2bc933749..dd4a3f06b 100644 --- a/lib/e2p/setversion.c +++ b/lib/e2p/setversion.c @@ -34,7 +34,6 @@ int setversion (int fd, unsigned long version) ver = (int) version; return ioctl (fd, EXT2_IOC_SETVERSION, &ver); #else /* ! HAVE_EXT2_IOCTLS */ - extern int errno; errno = EOPNOTSUPP; return -1; #endif /* ! HAVE_EXT2_IOCTLS */ diff --git a/lib/ss/execute_cmd.c b/lib/ss/execute_cmd.c index 2e2c8cfa0..d092134a3 100644 --- a/lib/ss/execute_cmd.c +++ b/lib/ss/execute_cmd.c @@ -17,8 +17,6 @@ #endif #ifdef HAVE_ERRNO_H #include <errno.h> -#else -extern int errno; #endif #include "ss_internal.h" #include <stdio.h> diff --git a/lib/ss/help.c b/lib/ss/help.c index a22b40178..54c78f239 100644 --- a/lib/ss/help.c +++ b/lib/ss/help.c @@ -20,8 +20,6 @@ #endif #ifdef HAVE_ERRNO_H #include <errno.h> -#else -extern int errno; #endif #include <fcntl.h> #include <sys/param.h> diff --git a/lib/ss/pager.c b/lib/ss/pager.c index b9b889962..ba32b2019 100644 --- a/lib/ss/pager.c +++ b/lib/ss/pager.c @@ -20,8 +20,6 @@ #endif #ifdef HAVE_ERRNO_H #include <errno.h> -#else -extern int errno; #endif #include "ss_internal.h" -- 2.39.0