From f43efe0c12008a7118f812f4e5221782a7b298a0 Mon Sep 17 00:00:00 2001
From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Sat, 28 Jun 2008 11:20:45 +0000
Subject: [PATCH] v4 preprocessor mex: various minor fixed to ensure correct
 compilation under g++ 4.3

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1906 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 ComputingTasks.cc             |  1 +
 DataTree.cc                   |  1 +
 ModFile.cc                    |  1 +
 ModelBlocks.cc                | 26 ++++++++++++++------------
 ModelTree.cc                  |  7 ++++---
 Model_Graph.cc                |  1 +
 NumericalConstants.cc         |  1 +
 ParsingDriver.cc              |  1 +
 SymbolTable.cc                | 10 ++++++----
 include/BlockTriangular.hh    |  2 +-
 include/ExprNode.hh           |  8 ++++----
 include/ModelNormalization.hh | 14 +++++++-------
 include/Model_Graph.hh        |  6 +++---
 include/SymbolGaussElim.hh    |  4 ++--
 macro/MacroDriver.cc          |  1 +
 15 files changed, 48 insertions(+), 36 deletions(-)

diff --git a/ComputingTasks.cc b/ComputingTasks.cc
index 9afcb7e2..f139a019 100644
--- a/ComputingTasks.cc
+++ b/ComputingTasks.cc
@@ -17,6 +17,7 @@
  * along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <cstdlib>
 #include <iostream>
 #include <sstream>
 
diff --git a/DataTree.cc b/DataTree.cc
index 0ad4d410..e2b31be2 100644
--- a/DataTree.cc
+++ b/DataTree.cc
@@ -17,6 +17,7 @@
  * along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <cstdlib>
 #include <iostream>
 
 #include "DataTree.hh"
diff --git a/ModFile.cc b/ModFile.cc
index 045941c0..cb1b1cab 100644
--- a/ModFile.cc
+++ b/ModFile.cc
@@ -17,6 +17,7 @@
  * along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <cstdlib>
 #include <iostream>
 #include <fstream>
 
diff --git a/ModelBlocks.cc b/ModelBlocks.cc
index 3c202b4a..f37117a2 100644
--- a/ModelBlocks.cc
+++ b/ModelBlocks.cc
@@ -71,18 +71,20 @@ Blocks::block_depth_search(int v)
         {
           // Update low_link no. */
           if(visit_nos[w] < low_link_nos[v])
-            if(visit_nos[w]>=0)
-              low_link_nos[v] = visit_nos[w];
-            else
-              {
-                // Check for hierarchic structure accross strong connex components
-                if(pos_sc[-(visit_nos[w]+2)]<pos_sc[n_sets])
-                  {
-                    int j=pos_sc[-(visit_nos[w]+2)];
-                    pos_sc[-(visit_nos[w]+2)]=pos_sc[n_sets];
-                    pos_sc[n_sets]=j;
-                  }
-              }
+            {
+              if(visit_nos[w]>=0)
+                low_link_nos[v] = visit_nos[w];
+              else
+                {
+                  // Check for hierarchic structure accross strong connex components
+                  if(pos_sc[-(visit_nos[w]+2)]<pos_sc[n_sets])
+                    {
+                      int j=pos_sc[-(visit_nos[w]+2)];
+                      pos_sc[-(visit_nos[w]+2)]=pos_sc[n_sets];
+                      pos_sc[n_sets]=j;
+                    }
+                }
+            }
         }
       edge_ptr = edge_ptr->next;
     }
diff --git a/ModelTree.cc b/ModelTree.cc
index ca1c056f..d475a87a 100644
--- a/ModelTree.cc
+++ b/ModelTree.cc
@@ -17,10 +17,11 @@
  * along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <cstdlib>
 #include <iostream>
 #include <fstream>
 #include <sstream>
-
+#include <cstring>
 #include <cmath>
 
 #include "ModelTree.hh"
@@ -1146,13 +1147,13 @@ ModelTree::writeModelStaticEquationsOrdered_M(ostream &output, Model_Block *Mode
 void
 ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Block *ModelBlock, const string bin_basename, ExprNodeOutputType output_type) const
   {
-    typedef struct Uff_l
+    struct Uff_l
       {
         int u, var, lag;
         Uff_l *pNext;
       };
 
-    typedef struct Uff
+    struct Uff
       {
         Uff_l *Ufl, *Ufl_First;
         int eqr;
diff --git a/Model_Graph.cc b/Model_Graph.cc
index 562f2102..bd93d547 100644
--- a/Model_Graph.cc
+++ b/Model_Graph.cc
@@ -19,6 +19,7 @@
 
 #include <cstdlib>
 #include <cstdio>
+#include <cstring>
 #include <iostream>
 #include <string>
 #include <ctime>
diff --git a/NumericalConstants.cc b/NumericalConstants.cc
index 93a28342..b17701da 100644
--- a/NumericalConstants.cc
+++ b/NumericalConstants.cc
@@ -17,6 +17,7 @@
  * along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <cstdlib>
 #include <iostream>
 
 #include "NumericalConstants.hh"
diff --git a/ParsingDriver.cc b/ParsingDriver.cc
index 1fdafef9..1c498bed 100644
--- a/ParsingDriver.cc
+++ b/ParsingDriver.cc
@@ -17,6 +17,7 @@
  * along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <cstdlib>
 #include <fstream>
 #include <iostream>
 
diff --git a/SymbolTable.cc b/SymbolTable.cc
index 5e2b84a1..849050a2 100644
--- a/SymbolTable.cc
+++ b/SymbolTable.cc
@@ -32,10 +32,12 @@ void
 SymbolTable::addSymbol(const string &name, Type type, const string &tex_name) throw (AlreadyDeclaredException)
 {
   if (exists(name))
-    if (symbol_table[name].first == type)
-      throw AlreadyDeclaredException(name, true);
-    else
-      throw AlreadyDeclaredException(name, false);
+    {
+      if (symbol_table[name].first == type)
+        throw AlreadyDeclaredException(name, true);
+      else
+        throw AlreadyDeclaredException(name, false);
+    }
 
   int id;
 
diff --git a/include/BlockTriangular.hh b/include/BlockTriangular.hh
index 323b3666..ceb96dda 100644
--- a/include/BlockTriangular.hh
+++ b/include/BlockTriangular.hh
@@ -33,7 +33,7 @@
 
 #include "ExprNode.hh"
 
-typedef struct List_IM
+struct List_IM
 {
   List_IM* pNext;
   int lead_lag;
diff --git a/include/ExprNode.hh b/include/ExprNode.hh
index 2e8fb3bb..cb74b35e 100644
--- a/include/ExprNode.hh
+++ b/include/ExprNode.hh
@@ -36,7 +36,7 @@ class DataTree;
 
 typedef class ExprNode *NodeID;
 
-typedef struct Model_Block;
+struct Model_Block;
 
 struct ExprNodeLess;
 
@@ -311,13 +311,13 @@ public:
   virtual void compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, map_idx_type map_idx) const;
 };
 
-typedef struct IM_compact
+struct IM_compact
 {
   int size, u_init, u_finish, nb_endo;
   int *u, *us, *Var, *Equ, *Var_Index, *Equ_Index, *Var_dyn_Index;
 };
 
-typedef struct Block
+struct Block
 {
   int Size, Sized, Type, Simulation_Type, Max_Lead, Max_Lag, Nb_Lead_Lag_Endo;
   bool is_linear;
@@ -329,7 +329,7 @@ typedef struct Block
   int Code_Start, Code_Length;
 };
 
-typedef struct Model_Block
+struct Model_Block
 {
   int Size, Periods;
   Block* Block_List;
diff --git a/include/ModelNormalization.hh b/include/ModelNormalization.hh
index e6a1c1ab..dc99b87c 100644
--- a/include/ModelNormalization.hh
+++ b/include/ModelNormalization.hh
@@ -23,27 +23,27 @@
 #include "CodeInterpreter.hh"
 
 
-typedef struct Edge
+struct Edge
 {
   Edge *next;
   int Vertex_Index;
 };
 
-typedef struct Equation_vertex
+struct Equation_vertex
 {
   Edge *First_Edge;
   Edge *Next_Edge;
   int matched;
 };
 
-typedef struct Equation_set
+struct Equation_set
 {
   Equation_vertex *Number;
   int size;
   int edges;
 };
 
-typedef struct simple
+struct simple
 {
   int index, block;
   bool available;
@@ -52,16 +52,16 @@ typedef struct simple
 class Normalization
 {
 private:
-  typedef struct Variable_vertex
+  struct Variable_vertex
   {
     int  matched;
   };
-  typedef struct Variable_set
+  struct Variable_set
   {
     Variable_vertex *Number;
     int size;
   };
-  typedef struct t_Heap
+  struct t_Heap
   {
     int u;        /* vertex */
     int i_parent; /* index in t_Heap of parent vertex in tree of u */
diff --git a/include/Model_Graph.hh b/include/Model_Graph.hh
index 5a38774d..7a6dfa7c 100644
--- a/include/Model_Graph.hh
+++ b/include/Model_Graph.hh
@@ -31,12 +31,12 @@
 #include "ModelTree.hh"
 #include "BlockTriangular.hh"
 
-typedef struct t_edge
+struct t_edge
 {
   int index, u_count;
 };
 
-typedef struct t_vertex
+struct t_vertex
 {
   t_edge *out_degree_edge, *in_degree_edge;
   int nb_out_degree_edges, nb_in_degree_edges;
@@ -44,7 +44,7 @@ typedef struct t_vertex
   int index, lag_lead;
 };
 
-typedef struct t_model_graph
+struct t_model_graph
 {
   int nb_vertices;
   t_vertex* vertex;
diff --git a/include/SymbolGaussElim.hh b/include/SymbolGaussElim.hh
index f83a8438..9fdb8a92 100644
--- a/include/SymbolGaussElim.hh
+++ b/include/SymbolGaussElim.hh
@@ -27,13 +27,13 @@
 using namespace std;
 #define TOL 1e-9
 
-typedef struct t_table_y
+struct t_table_y
 {
   int index,nb;
   int *u_index, *y_index;
 };
 
-typedef struct t_table_u
+struct t_table_u
 {
   t_table_u* pNext;
   unsigned char type;
diff --git a/macro/MacroDriver.cc b/macro/MacroDriver.cc
index cd6b11c2..adfc596c 100644
--- a/macro/MacroDriver.cc
+++ b/macro/MacroDriver.cc
@@ -17,6 +17,7 @@
  * along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <cstdlib>
 #include <iostream>
 #include <fstream>
 
-- 
GitLab