diff --git a/CImg.h b/CImg.h
index 66d06e79263a0aa1989ecc8f68f0a68dc7a79248..9b408c74775ed036937839ce5b9f0749e378d957 100644
--- a/CImg.h
+++ b/CImg.h
@@ -6172,27 +6172,8 @@ namespace cimg_library_suffixed {
     }
 
     // Open a file (similar to std:: fopen(), but with wide character support on Windows).
-    inline std::FILE *std_fopen(const char *const path, const char *const mode) {
-      std::FILE *const res = std::fopen(path,mode);
-      if (res) return res;
-#if cimg_OS==2
-      // Try alternative method, with wide-character string.
-      int err = MultiByteToWideChar(CP_UTF8,0,path,-1,0,0);
-      if (err) {
-        CImg<wchar_t> wpath(err);
-        err = MultiByteToWideChar(CP_UTF8,0,path,-1,wpath,err);
-        if (err) { // Convert 'mode' to a wide-character string.
-          err = MultiByteToWideChar(CP_UTF8,0,mode,-1,0,0);
-          if (err) {
-            CImg<wchar_t> wmode(err);
-            if (MultiByteToWideChar(CP_UTF8,0,mode,-1,wmode,err))
-              return _wfopen(wpath,wmode);
-          }
-        }
-      }
-#endif
-      return 0;
-    }
+    inline std::FILE *std_fopen(const char *const path, const char *const mode);
+
 
     //! Open a file.
     /**
@@ -59827,6 +59808,29 @@ namespace cimg {
 #endif
   }
 
+  // Open a file (similar to std:: fopen(), but with wide character support on Windows).
+  inline std::FILE *std_fopen(const char *const path, const char *const mode) {
+    std::FILE *const res = std::fopen(path,mode);
+    if (res) return res;
+#if cimg_OS==2
+    // Try alternative method, with wide-character string.
+    int err = MultiByteToWideChar(CP_UTF8,0,path,-1,0,0);
+    if (err) {
+      CImg<wchar_t> wpath(err);
+      err = MultiByteToWideChar(CP_UTF8,0,path,-1,wpath,err);
+      if (err) { // Convert 'mode' to a wide-character string.
+        err = MultiByteToWideChar(CP_UTF8,0,mode,-1,0,0);
+        if (err) {
+          CImg<wchar_t> wmode(err);
+          if (MultiByteToWideChar(CP_UTF8,0,mode,-1,wmode,err))
+            return _wfopen(wpath,wmode);
+        }
+      }
+    }
+#endif
+    return 0;
+  }
+
   //! Get/set path to store temporary files.
   /**
      \param user_path Specified path, or \c 0 to get the path currently used.