When an ANSI/C90 plugin compiled with ‘-pedantic’ uses
NBDKIT_HANDLE_NOT_NEEDED it gets the error:
ISO C forbids conversion of function pointer to object pointer type
This is because the existing macro worked by returning a function
pointer but in C90 function pointers cannot be cast to data pointers
since on some ancient architectures code and data pointers were
incompatible.
We only need a convenient global data pointer here, and the address of
‘errno’ should be fine.
---
include/nbdkit-common.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/nbdkit-common.h b/include/nbdkit-common.h
index 36fce20..cb9954e 100644
--- a/include/nbdkit-common.h
+++ b/include/nbdkit-common.h
@@ -40,6 +40,7 @@
#include <stdarg.h>
#include <stdint.h>
+#include <errno.h>
#ifdef __cplusplus
extern "C" {
@@ -78,7 +79,7 @@ extern char *nbdkit_realpath (const char *path);
/* A static non-NULL pointer which can be used when you don't need a
* per-connection handle.
*/
-#define NBDKIT_HANDLE_NOT_NEEDED ((void *) &nbdkit_error)
+#define NBDKIT_HANDLE_NOT_NEEDED (&errno)
#ifdef __cplusplus
}
--
2.20.1