diff --git a/src/plot/32bpp-xbgr8888.c b/src/plot/32bpp-xbgr8888.c
index 89131b4..e8ff2e9 100644
--- a/src/plot/32bpp-xbgr8888.c
+++ b/src/plot/32bpp-xbgr8888.c
@@ -10,12 +10,18 @@
 #include <stdbool.h>
 #include <stdlib.h>
 
-#ifndef _WIN32
-#include <endian.h>
-#else
+#if defined(__APPLE__)
+#include <machine/endian.h>
+#define __BYTE_ORDER __DARWIN_BYTE_ORDER
+#define __BIG_ENDIAN __DARWIN_BIG_ENDIAN
+#endif
+#if defined(_WIN32)
 #define __BYTE_ORDER __BYTE_ORDER__
 #define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
 #endif
+#if !(defined(__APPLE__) || defined(_WIN32))
+#include <endian.h>
+#endif
 
 #include "libnsfb.h"
 #include "libnsfb_plot.h"
diff --git a/src/plot/32bpp-xrgb8888.c b/src/plot/32bpp-xrgb8888.c
index 476f6b2..8e3a710 100644
--- a/src/plot/32bpp-xrgb8888.c
+++ b/src/plot/32bpp-xrgb8888.c
@@ -10,12 +10,18 @@
 #include <stdbool.h>
 #include <stdlib.h>
 
-#ifndef _WIN32
-#include <endian.h>
-#else
+#if defined(__APPLE__)
+#include <machine/endian.h>
+#define __BYTE_ORDER __DARWIN_BYTE_ORDER
+#define __BIG_ENDIAN __DARWIN_BIG_ENDIAN
+#endif
+#if defined(_WIN32)
 #define __BYTE_ORDER __BYTE_ORDER__
 #define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
 #endif
+#if !(defined(__APPLE__) || defined(_WIN32))
+#include <endian.h>
+#endif
 
 #include "libnsfb.h"
 #include "libnsfb_plot.h"
