From ad9ac0a311b0d7d274b0c2a34979ae82f1521b32 Mon Sep 17 00:00:00 2001
From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Mon, 24 Nov 2008 10:55:37 +0000
Subject: [PATCH] trunk preprocessor: compilation fix for Linux/Unix systems

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@2270 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 preprocessor/ModelTree.cc | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/preprocessor/ModelTree.cc b/preprocessor/ModelTree.cc
index 02f9ae9665..c19275fe15 100644
--- a/preprocessor/ModelTree.cc
+++ b/preprocessor/ModelTree.cc
@@ -23,7 +23,15 @@
 #include <sstream>
 #include <cstring>
 #include <cmath>
-#include <direct.h>
+
+// For mkdir() and chdir()
+#ifdef _WIN32
+# include <direct.h>
+#else
+# include <unistd.h>
+# include <sys/stat.h>
+# include <sys/types.h>
+#endif
 
 #include "ModelTree.hh"
 
@@ -3131,7 +3139,12 @@ ModelTree::writeDynamicFile(const string &basename) const
       writeDynamicMFile(basename + "_dynamic");
       break;
     case eSparseMode:
-      mkdir(basename.c_str()/*, 0775*/);  // create a directory to store all the files
+      // create a directory to store all the files
+#ifdef _WIN32
+      mkdir(basename.c_str());
+#else
+      mkdir(basename.c_str(), 0777);
+#endif
       writeSparseDynamicMFile(basename + "_dynamic", basename, mode);
       block_triangular.Free_Block(block_triangular.ModelBlock);
       block_triangular.incidencematrix.Free_IM();
@@ -3141,7 +3154,12 @@ ModelTree::writeDynamicFile(const string &basename) const
       writeDynamicCFile(basename + "_dynamic");
       break;
     case eSparseDLLMode:
-      mkdir(basename.c_str()/*, 0775*/);  // create a directory to store all the files
+      // create a directory to store all the files
+#ifdef _WIN32
+      mkdir(basename.c_str());
+#else
+      mkdir(basename.c_str(), 0777);
+#endif
       writeModelEquationsCodeOrdered(basename + "_dynamic", block_triangular.ModelBlock, basename, oCDynamicModelSparseDLL);
       block_triangular.Free_Block(block_triangular.ModelBlock);
       block_triangular.incidencematrix.Free_IM();
-- 
GitLab