--- a/src/xls.c
+++ b/src/xls.c
@@ -71,6 +71,11 @@
  * \return -1 on error
  */
 
+#ifdef USELOCALE
+#include <locale.h>
+#include <langinfo.h>
+#endif
+
 int open_xls(char * fname, char * encoding) {
 #ifdef XLS
 
@@ -78,8 +83,6 @@
     char fmt[15] = "%d/%m/%Y";
 
     #ifdef USELOCALE
-    #include <locale.h>
-    #include <langinfo.h>
     char * loc = NULL;
     char * f = NULL;
     loc = setlocale(LC_TIME, "");
