+// API of gif_lib has changed recenly
+#ifndef GIFLIB_MAJOR
+#define GIFLIB_MAJOR 0
+#endif
+#if GIFLIB_MAJOR > 5 || GIFLIB_MAJOR == 5 && GIFLIB_MINOR >= 1
+static int dgif_error_code; // Scratch pad only, no locking needed
+#define DGIF_OPEN(_userptr, _readfunc) DGifOpen(_userptr, _readfunc, &dgif_error_code)
+#define DGIF_CLOSE_FILE(_gif) DGifCloseFile(_gif, &dgif_error_code)
+#else
+#define DGIF_OPEN(_userptr, _readfunc) DGifOpen(_userptr, _readfunc)
+#define DGIF_CLOSE_FILE(_gif) DGifCloseFile(_gif)
+#endif
+