diff --git a/BlockTriangular.cc b/BlockTriangular.cc
index cbb60c6cdc115fbd631e26ded8f8982928a2a447..b21c48c1f0b775cd0a8419207665b8fc6c1e5dc5 100644
--- a/BlockTriangular.cc
+++ b/BlockTriangular.cc
@@ -130,7 +130,7 @@ BlockTriangular::bGet_IM(int lead_lag) const
   if((Cur_IM->lead_lag != lead_lag) || (Cur_IM==NULL))
     {
       cout << "the incidence matrix with lag " << lead_lag << " does not exist !!";
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
   return (Cur_IM->IM);
 }
@@ -148,7 +148,7 @@ BlockTriangular::fill_IM(int equation, int variable_endo, int lead_lag)
     {
       cout << "Error : The model has more equations (at least " << equation + 1 << ") than declared endogenous variables (" << endo_nbr << ")\n";
       system("PAUSE");
-      exit( -1);
+      exit(EXIT_FAILURE);
     }
   if (!Cur_IM)
     Cur_IM = Build_IM(lead_lag);
@@ -167,7 +167,7 @@ BlockTriangular::unfill_IM(int equation, int variable_endo, int lead_lag)
     {
     cout << "Error : The model has more equations (at least " << equation + 1 << ") than declared endogenous variables (" << endo_nbr << ")\n";
     system("PAUSE");
-    exit( -1);
+    exit(EXIT_FAILURE);
     }*/
   if (!Cur_IM)
     Cur_IM = Build_IM(lead_lag);
@@ -409,7 +409,7 @@ BlockTriangular::Allocate_Block(int size, int *count_Equ, int *count_Block, Bloc
                   if(IM == NULL)
                     {
                       cout << "Error IM(" << li - Lag << ") doesn't exist\n";
-                      exit( -1);
+                      exit(EXIT_FAILURE);
                     }
                   if(IM[Index_Var_IM[*count_Equ].index + Index_Equ_IM[*count_Equ].index*endo_nbr] && nb_lead_lag_endo)
                     {
@@ -564,7 +564,7 @@ BlockTriangular::Allocate_Block(int size, int *count_Equ, int *count_Block, Bloc
           else
             {
               cout << "Error IM(" << i - Lag << ") doesn't exist\n";
-              exit( -1);
+              exit(EXIT_FAILURE);
             }
           for(j = first_count_equ;j < size + first_count_equ;j++)
             {
@@ -809,7 +809,7 @@ BlockTriangular::Normalize_and_BlockDecompose(bool* IM, Model_Block* ModelBlock,
                   normalization.Set_fp_verbose(true);
                   OK=normalization.Normalize(n, *prologue, *epilogue, SIM00, Index_Equ_IM, Equation_gr, 1, IM);
                   cout << "Error\n";
-                  exit(-1);
+                  exit(EXIT_FAILURE);
                 }
             }
           else
diff --git a/ComputingTasks.cc b/ComputingTasks.cc
index 3c070ec73a8613ac1315866bbc8fe49579cc7a53..23e4973a89db607f0b6db1699424acdbdcdb1a76 100644
--- a/ComputingTasks.cc
+++ b/ComputingTasks.cc
@@ -832,7 +832,7 @@ PlannerObjectiveStatement::checkPass(ModFileStructure &mod_file_struct)
   if (model_tree->equation_number() != 1)
     {
       cerr << "ERROR: planer_objective: should have only one equation!" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 }
 
diff --git a/DataTree.cc b/DataTree.cc
index 4579db474b984272d1b02c266ec9c80a52c41c36..487646ac967fe04ec43278cecdffbc6eed8f1397 100644
--- a/DataTree.cc
+++ b/DataTree.cc
@@ -163,7 +163,7 @@ DataTree::AddDivide(NodeID iArg1, NodeID iArg2)
   else
     {
       cerr << "Division by zero!" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 }
 
@@ -235,7 +235,7 @@ DataTree::AddLog(NodeID iArg1)
   else
     {
       cerr << "log(0) isn't available" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 }
 
@@ -248,7 +248,7 @@ NodeID DataTree::AddLog10(NodeID iArg1)
   else
     {
       cerr << "log10(0) isn't available" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 }
 
@@ -412,7 +412,7 @@ DataTree::AddUnknownFunction(const string &function_name, const vector<NodeID> &
   if (symbol_table.getType(function_name) != eUnknownFunction)
     {
       cerr << "Symbol " << function_name << " is not a function name!";
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 
   int id = symbol_table.getID(function_name);
diff --git a/DynareFlex.ll b/DynareFlex.ll
index a7df257fc7b8eb21329e198ca3829a528690ded1..e64d6fc605e3d60f620e5fc33e278ac189451dc1 100644
--- a/DynareFlex.ll
+++ b/DynareFlex.ll
@@ -433,7 +433,7 @@ int
 DynareFlexLexer::yylex()
 {
   cerr << "DynareFlexLexer::yylex() has been called, that should never happen!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 /*
diff --git a/DynareMain.cc b/DynareMain.cc
index 832bd0d41bbf842f0c7594001cfc81751725763c..b571a3a87c88b1b7b99b839be71c70e89623f94f 100644
--- a/DynareMain.cc
+++ b/DynareMain.cc
@@ -83,7 +83,7 @@ main(int argc, char** argv)
   if (ext != string(".mod") && ext != string(".dyn"))
     {
       cerr << "mod_file extension must be .mod or .dyn!" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
   basename.erase(basename.size() - 4, 4);
 
@@ -102,5 +102,5 @@ main(int argc, char** argv)
   // Do the rest
   main2(macro_output, basename, debug, clear_all, no_tmp_terms);
 
-  return 0;
+  return EXIT_SUCCESS;
 }
diff --git a/ExprNode.cc b/ExprNode.cc
index f978044f7aa911cf949c2da4df4d0e315dbf4d5a..592b5d213f21f86fa9493b4f1f007f6626d35dc7 100644
--- a/ExprNode.cc
+++ b/ExprNode.cc
@@ -185,7 +185,7 @@ VariableNode::VariableNode(DataTree &datatree_arg, int symb_id_arg, SymbolType t
   if ((type == eModelLocalVariable || type == eModFileLocalVariable || type == eUnknownFunction) && lag != 0)
     {
       cerr << "Attempt to construct a VariableNode for local variable or unknown function with non-zero lead/lag" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 
   // Fill in non_null_derivatives
@@ -209,7 +209,7 @@ VariableNode::VariableNode(DataTree &datatree_arg, int symb_id_arg, SymbolType t
       break;
     case eUnknownFunction:
       cerr << "Attempt to construct a VariableNode with an unknown function name" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 }
 
@@ -231,13 +231,13 @@ VariableNode::computeDerivative(int varID)
       return datatree.local_variables_table[symb_id]->getDerivative(varID);
     case eModFileLocalVariable:
       cerr << "ModFileLocalVariable is not derivable" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     case eUnknownFunction:
       cerr << "Impossible case!" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
   cerr << "Impossible case!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 void
@@ -343,7 +343,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
           if (lag != 0)
             {
               cerr << "VariableNode::writeOutput: lag != 0 for exogenous variable outside model scope!" << endl;
-              exit(-1);
+              exit(EXIT_FAILURE);
             }
           output <<  "oo_.exo_steady_state" << "(" << i << ")";
           break;
@@ -381,7 +381,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
           if (lag != 0)
             {
               cerr << "VariableNode::writeOutput: lag != 0 for exogenous determistic variable outside model scope!" << endl;
-              exit(-1);
+              exit(EXIT_FAILURE);
             }
           output <<  "oo_.exo_det_steady_state" << "(" << symb_id + 1 << ")";
           break;
@@ -390,7 +390,7 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
 
     case eUnknownFunction:
       cerr << "Impossible case" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 }
 
@@ -459,10 +459,10 @@ VariableNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType ou
     case eModelLocalVariable:
     case eModFileLocalVariable:
       cerr << "VariableNode::compile: unhandled variable type" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     case eUnknownFunction:
       cerr << "Impossible case" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 }
 
@@ -552,7 +552,7 @@ UnaryOpNode::computeDerivative(int varID)
       return datatree.AddDivide(darg, t11);
     }
   cerr << "Impossible case!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 int
@@ -637,7 +637,7 @@ UnaryOpNode::cost(const temporary_terms_type &temporary_terms, bool is_matlab) c
         return cost + 90;
       }
   cerr << "Impossible case!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 void
@@ -951,7 +951,7 @@ BinaryOpNode::computeDerivative(int varID)
       return datatree.AddMinus(darg1, darg2);
     }
   cerr << "Impossible case!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 int
@@ -991,7 +991,7 @@ BinaryOpNode::precedence(ExprNodeOutputType output_type, const temporary_terms_t
       return 100;
     }
   cerr << "Impossible case!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 int
@@ -1056,7 +1056,7 @@ BinaryOpNode::cost(const temporary_terms_type &temporary_terms, bool is_matlab)
         return cost;
       }
   cerr << "Impossible case!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 void
@@ -1153,7 +1153,7 @@ BinaryOpNode::eval_opcode(double v1, BinaryOpcode op_code, double v2) throw (Eva
       throw EvalException();
     }
   cerr << "Impossible case!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 double
@@ -1399,7 +1399,7 @@ TrinaryOpNode::computeDerivative(int varID)
       return datatree.AddTimes(t11, t15);
     }
   cerr << "Impossible case!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 int
@@ -1416,7 +1416,7 @@ TrinaryOpNode::precedence(ExprNodeOutputType output_type, const temporary_terms_
       return 100;
     }
   cerr << "Impossible case!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 int
@@ -1445,7 +1445,7 @@ TrinaryOpNode::cost(const temporary_terms_type &temporary_terms, bool is_matlab)
         return cost+1000;
       }
   cerr << "Impossible case!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 void
@@ -1510,10 +1510,10 @@ TrinaryOpNode::eval_opcode(double v1, TrinaryOpcode op_code, double v2, double v
     {
     case oNormcdf:
       cerr << "NORMCDF: eval not implemented" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
   cerr << "Impossible case!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 double
@@ -1554,7 +1554,7 @@ TrinaryOpNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
   if (!OFFSET(output_type))
     {
       cerr << "TrinaryOpNode not implemented for C output" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 
   // If current node is a temporary term
@@ -1603,7 +1603,7 @@ NodeID
 UnknownFunctionNode::computeDerivative(int varID)
 {
   cerr << "UnknownFunctionNode::computeDerivative: operation impossible!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 void
@@ -1612,7 +1612,7 @@ UnknownFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
                                            bool is_matlab) const
 {
   cerr << "UnknownFunctionNode::computeTemporaryTerms: operation impossible!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 void UnknownFunctionNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
@@ -1639,7 +1639,7 @@ UnknownFunctionNode::computeTemporaryTerms(map<NodeID, int> &reference_count,
                                            map_idx_type &map_idx) const
 {
   cerr << "UnknownFunctionNode::computeTemporaryTerms: not implemented" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 void
@@ -1660,5 +1660,5 @@ void
 UnknownFunctionNode::compile(ofstream &CompileCode, bool lhs_rhs, ExprNodeOutputType output_type, const temporary_terms_type &temporary_terms, map_idx_type map_idx) const
 {
   cerr << "UnknownFunctionNode::compile: operation impossible!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
diff --git a/ModFile.cc b/ModFile.cc
index 6997ee50f18ed6122a8d10ab69b09cf438b2a397..495b030a230496fd686d849ef5a6dbbce1dd56e2 100644
--- a/ModFile.cc
+++ b/ModFile.cc
@@ -66,13 +66,13 @@ ModFile::checkPass()
           || stochastic_statement_present))
     {
       cerr << "ERROR: At least one model equation must be declared!" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 
   if (mod_file_struct.simul_present && stochastic_statement_present)
     {
       cerr << "ERROR: A .mod file cannot contain both a simul command and one of {stoch_simul, estimation, forecast, osr, ramsey_policy}" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 
   /*
@@ -86,7 +86,7 @@ ModFile::checkPass()
       && (model_tree.equation_number() != symbol_table.endo_nbr))
     {
       cerr << "ERROR: There are " << model_tree.equation_number() << " equations but " << symbol_table.endo_nbr << " endogenous variables!" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 }
 
@@ -104,7 +104,7 @@ ModFile::computingPass(bool no_tmp_terms)
           if (mod_file_struct.order_option < 1 || mod_file_struct.order_option > 3)
             {
               cerr << "Incorrect order option..." << endl;
-              exit(-1);
+              exit(EXIT_FAILURE);
             }
           model_tree.computeJacobianExo = true;
           if (mod_file_struct.order_option >= 2)
@@ -135,13 +135,13 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all) const
         {
           cerr << "ERROR: Can't open file " << fname
                << " for writing" << endl;
-          exit(-1);
+          exit(EXIT_FAILURE);
         }
     }
   else
     {
       cerr << "ERROR: Missing file name" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 
   mOutputFile << "%" << endl
diff --git a/ModelNormalization.cc b/ModelNormalization.cc
index 75dfe62b57eaf47b53430c524c168af38b91e605..039fd2cfe47665f6395b42b56e774620f8202ded 100644
--- a/ModelNormalization.cc
+++ b/ModelNormalization.cc
@@ -535,7 +535,7 @@ Normalization::Normalize(int n, int prologue, int epilogue, bool* IM, simple* In
       cout << "\n could not be normalized\n";
       //ErrorHandling(n, IM, Index_Equ_IM);
       //system("PAUSE");
-      exit( -1);
+      exit(EXIT_FAILURE);
     }
   if(matchingSize >= effective_n )
     {
diff --git a/ModelTree.cc b/ModelTree.cc
index 513a2e4fce75896e125d828759f4bef2bd28e7f4..59fda03276ed3bf81eb58c009a483c1c73680167 100644
--- a/ModelTree.cc
+++ b/ModelTree.cc
@@ -1002,7 +1002,7 @@ ModelTree::writeModelEquationsCodeOrdered(const string file_name, const Model_Bl
     if (!code_file.is_open())
       {
         cout << "Error : Can't open file \"" << main_name << "\" for writing\n";
-        exit( -1);
+        exit(EXIT_FAILURE);
       }
     //Temporary variables declaration
     code_file.write(&FDIMT, sizeof(FDIMT));
@@ -1366,7 +1366,7 @@ ModelTree::writeStaticMFile(const string &static_basename) const
   if (!mStaticModelFile.is_open())
     {
       cerr << "Error: Can't open file " << filename << " for writing" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
   // Writing comments and function definition command
   mStaticModelFile << "function [residual, g1, g2] = " << static_basename << "(y, x, params)" << endl
@@ -1392,7 +1392,7 @@ ModelTree::writeDynamicMFile(const string &dynamic_basename) const
   if (!mDynamicModelFile.is_open())
     {
       cerr << "Error: Can't open file " << filename << " for writing" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
   mDynamicModelFile << "function [residual, g1, g2, g3] = " << dynamic_basename << "(y, x, params, it_)" << endl
                     << "%" << endl
@@ -1416,7 +1416,7 @@ ModelTree::writeStaticCFile(const string &static_basename) const
   if (!mStaticModelFile.is_open())
     {
       cerr << "Error: Can't open file " << filename << " for writing" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
   mStaticModelFile << "/*" << endl
                    << " * " << filename << " : Computes static model for Dynare" << endl
@@ -1481,7 +1481,7 @@ ModelTree::writeDynamicCFile(const string &dynamic_basename) const
   if (!mDynamicModelFile.is_open())
     {
       cerr << "Error: Can't open file " << filename << " for writing" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
   mDynamicModelFile << "/*" << endl
                     << " * " << filename << " : Computes dynamic model for Dynare" << endl
@@ -1723,7 +1723,7 @@ ModelTree::Write_Inf_To_Bin_File(const string &dynamic_basename, const string &b
   if (!SaveCode.is_open())
     {
       cout << "Error : Can't open file \"" << bin_basename << ".bin\" for writing\n";
-      exit( -1);
+      exit(EXIT_FAILURE);
     }
   u_count_int=0;
   for(int m=0;m<=block_triangular.ModelBlock->Block_List[num].Max_Lead+block_triangular.ModelBlock->Block_List[num].Max_Lag;m++)
@@ -1782,7 +1782,7 @@ ModelTree::writeSparseStaticMFile(const string &static_basename, const string &b
   if (!mStaticModelFile.is_open())
     {
       cerr << "Error: Can't open file " << filename << " for writing" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
   mStaticModelFile << "%\n";
   mStaticModelFile << "% " << filename << " : Computes static model for Dynare\n";
@@ -2001,7 +2001,7 @@ ModelTree::writeSparseDynamicMFile(const string &dynamic_basename, const string
   if (!mDynamicModelFile.is_open())
     {
       cerr << "Error: Can't open file " << filename << " for writing" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
   mDynamicModelFile << "%\n";
   mDynamicModelFile << "% " << filename << " : Computes dynamic model for Dynare\n";
@@ -2308,7 +2308,7 @@ ModelTree::writeSparseDynamicMFile(const string &dynamic_basename, const string
             block_triangular.ModelBlock->Block_List[i].IM_lead_lag[block_triangular.ModelBlock->Block_List[i].Max_Lag + block_triangular.ModelBlock->Block_List[i].Max_Lead].u_finish + 1 << ", " << symbol_table.endo_nbr <<
             ", " << block_triangular.ModelBlock->Block_List[i].Max_Lag << ", " << block_triangular.ModelBlock->Block_List[i].Max_Lead << ");\n";
           cerr << "Not implemented block SOLVE_TWO_BOUNDARIES_COMPLETE" << endl;
-          exit(-1);
+          exit(EXIT_FAILURE);
         }*/
       else if ((k == SOLVE_FORWARD_COMPLETE) && (block_triangular.ModelBlock->Block_List[i].Size))
         {
@@ -2349,7 +2349,7 @@ ModelTree::writeSparseDynamicMFile(const string &dynamic_basename, const string
           mDynamicModelFile << "    end\n";
           mDynamicModelFile << "  end\n";
           /*cerr << "Not implemented block SOLVE_FORWARD_COMPLETE" << endl;
-          exit(-1);*/
+          exit(EXIT_FAILURE);*/
         }
       else if ((k == SOLVE_BACKWARD_COMPLETE) && (block_triangular.ModelBlock->Block_List[i].Size))
         {
@@ -2386,7 +2386,7 @@ ModelTree::writeSparseDynamicMFile(const string &dynamic_basename, const string
           mDynamicModelFile << "    end\n";
           mDynamicModelFile << "  end\n";
           /*cerr << "Not implemented block SOLVE_BACKWARD_COMPLETE" << endl;
-          exit(-1);*/
+          exit(EXIT_FAILURE);*/
         }
       else if ((k == SOLVE_TWO_BOUNDARIES_COMPLETE || k == SOLVE_TWO_BOUNDARIES_SIMPLE) && (block_triangular.ModelBlock->Block_List[i].Size))
         {
@@ -3012,7 +3012,7 @@ ModelTree::addEquation(NodeID eq)
   if (beq == NULL || beq->op_code != oEqual)
     {
       cerr << "ModelTree::addEquation: you didn't provide an equal node!" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 
   equations.push_back(beq);
diff --git a/Model_Graph.cc b/Model_Graph.cc
index bd93d54785edeaad998ee14377ea6307e77f3a3a..40fdc7fb3d4a3a06b731224d17f267a455967763 100644
--- a/Model_Graph.cc
+++ b/Model_Graph.cc
@@ -90,14 +90,14 @@ void Check_Graph(t_model_graph* model_graph)
               cout << "not symetric for edge between vertices " << model_graph->vertex[i1].index << " and " << model_graph->vertex[i].index << " (in_degree)\n";
               print_Graph(model_graph);
               system("pause");
-              exit( -1);
+              exit(EXIT_FAILURE);
             }
           if(!OK_u_count)
             {
               cout << "valeur de u_count non sym�trique sur l'arc entre " << model_graph->vertex[i1].index << " et " << model_graph->vertex[i].index << " (in_degree)\n";
               print_Graph(model_graph);
               system("pause");
-              exit( -1);
+              exit(EXIT_FAILURE);
             }
         }
       for(j = 0;j < model_graph->vertex[i].nb_out_degree_edges;j++)
@@ -120,14 +120,14 @@ void Check_Graph(t_model_graph* model_graph)
               cout << "pas sym�trique sur l'arc entre " << model_graph->vertex[i1].index << " et " << model_graph->vertex[i].index << " (out_degree)\n";
               print_Graph(model_graph);
               system("pause");
-              exit( -1);
+              exit(EXIT_FAILURE);
             }
           if(!OK_u_count)
             {
               cout << "valeur de u_count non sym�trique sur l'arc entre " << model_graph->vertex[i1].index << " et " << model_graph->vertex[i].index << " (out_degree)\n";
               print_Graph(model_graph);
               system("pause");
-              exit( -1);
+              exit(EXIT_FAILURE);
             }
         }
     }
@@ -361,7 +361,7 @@ ModelBlock_Graph(Model_Block *ModelBlock, int Blck_num, bool dynamic, t_model_gr
                                     {
                                       cout << "Error in model graph construction (lead part): j (" << j << ")>size (" << ModelBlock->Block_List[Blck_num].IM_lead_lag[lag1].size << ")\n";
                                       system("pause");
-                                      exit(-1);
+                                      exit(EXIT_FAILURE);
                                     }
                                   //#endif
                                   vertex_index[k2] = (lag + *periods - 1) * nb_endo + ModelBlock->Block_List[Blck_num].IM_lead_lag[lag1].Var_Index[j];
diff --git a/NumericalConstants.cc b/NumericalConstants.cc
index b17701dadab9f98e9e1d17eb4f214d6cb33d0c86..7f743023123ffaa3b46e0dbbe7c8ba44a4082857 100644
--- a/NumericalConstants.cc
+++ b/NumericalConstants.cc
@@ -39,7 +39,7 @@ NumericalConstants::AddConstant(const string &iConst)
   if (atof(iConst.c_str()) < 0)
     {
       cerr << "Can't handle a negative constant..!" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 
   int id = (int) mNumericalConstants.size();
@@ -56,7 +56,7 @@ NumericalConstants::get(int ID) const
   else
     {
       cerr << "Unknown constant" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 }
 
diff --git a/ParsingDriver.cc b/ParsingDriver.cc
index cd2cd313856332422ad27316aa2897d987343282..dcd1b6d343c229c463effc9ffcea237e15bf3cb9 100644
--- a/ParsingDriver.cc
+++ b/ParsingDriver.cc
@@ -78,7 +78,7 @@ void
 ParsingDriver::error(const Dynare::parser::location_type &l, const string &m)
 {
   cerr << "ERROR: " << l << ": " << m << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 void
diff --git a/SymbolGaussElim.cc b/SymbolGaussElim.cc
index f9d14ea33e2443d997922a8094af5834e0336fc1..f4d3452d970b636a2143d8f34c6bb9f323945bbb 100644
--- a/SymbolGaussElim.cc
+++ b/SymbolGaussElim.cc
@@ -60,7 +60,7 @@ SymbolicGaussElimination::set_free_u_list(int index)
             {
               cout << "Error to much j=" << j << " Maximum allowed=" << MAX_FREE_U_LIST << "\n";
               system("pause");
-              exit( -1);
+              exit(EXIT_FAILURE);
             }
         }
     }
@@ -68,7 +68,7 @@ SymbolicGaussElimination::set_free_u_list(int index)
     {
       cout << "Error to much i=" << i << " Maximum allowed=" << MAX_FREE_U_LIST << "\n";
       system("pause");
-      exit( -1);
+      exit(EXIT_FAILURE);
     }
   free_u_list[i] = index;
   nb_free_u_list++;
@@ -76,7 +76,7 @@ SymbolicGaussElimination::set_free_u_list(int index)
     {
       cout << "Error to much free_u_list=" << nb_free_u_list << " Maximum allowed=" << MAX_FREE_U_LIST << "\n";
       system("pause");
-      exit( -1);
+      exit(EXIT_FAILURE);
     }
   if(nb_free_u_list > max_nb_free_u_list)
     max_nb_free_u_list = nb_free_u_list;
@@ -281,7 +281,7 @@ store_code(t_table_u **save_table_u, t_table_u *First_table_u, t_table_u *stop_t
       if((table_u->type > 7) || (table_u->type < 1))
         {
           cout << "Error : table_u->type=" << int(table_u->type) << " *nb_save_table_u=" << *nb_save_table_u << "\n";
-          exit( -1);
+          exit(EXIT_FAILURE);
         }
       else
         {
@@ -489,7 +489,7 @@ SymbolicGaussElimination::interpolation(t_model_graph* model_graph, t_table_y* t
               cout << "first_u_blck=" << first_u_blck << " second_u_blck=" << second_u_blck << "\n";
               cout << "c_first_table_u->type=" << int(c_first_table_u->type) << " c_second_table_u->type=" << int(c_second_table_u->type) << "\n";
               system("pause");
-              exit( -1);
+              exit(EXIT_FAILURE);
             }
           switch (c_first_table_u->type)
             {
@@ -606,7 +606,7 @@ SymbolicGaussElimination::interpolation(t_model_graph* model_graph, t_table_y* t
                 {
                   cout << "c_first_table_u->pNext=" << c_first_table_u->pNext << " second_u_blck->pNext=" << second_u_blck->pNext << "\n";
                   cout << "Error not synchronize graph interpolation\n";
-                  exit( -1);
+                  exit(EXIT_FAILURE);
                 }
               OK = 0;
             }
@@ -821,7 +821,7 @@ SymbolicGaussElimination::Loop_Elimination(t_model_graph* model_graph)
               cout << "Error: not symetric on a loop on vertex " << model_graph->vertex[i].index << "\n";
               print_Graph(model_graph);
               system("pause");
-              exit( -1);
+              exit(EXIT_FAILURE);
             }
           for(j = pos + 1;j < model_graph->vertex[i].nb_out_degree_edges;j++)
             {
@@ -839,7 +839,7 @@ SymbolicGaussElimination::Loop_Elimination(t_model_graph* model_graph)
               cout << "Error: not symetric on a loop on vertex " << model_graph->vertex[i].index << "\n";
               print_Graph(model_graph);
               system("pause");
-              exit( -1);
+              exit(EXIT_FAILURE);
             }
           for(j = pos + 1;j < model_graph->vertex[i].nb_in_degree_edges;j++)
             {
@@ -988,7 +988,7 @@ SymbolicGaussElimination::Vertex_Elimination(t_model_graph* model_graph, int pos
                       if(a_loop >= size)
                         {
                           cout << "Error : a_loop (" << a_loop << ") >= " << size << "\n";
-                          exit( -1);
+                          exit(EXIT_FAILURE);
                         }
                       s_j2[a_loop] = j2;
                       s_i2[a_loop] = i2;
@@ -1113,7 +1113,7 @@ SymbolicGaussElimination::Vertex_Elimination(t_model_graph* model_graph, int pos
               cout << "error: Model_Graph not correctly filled in out_degree (edge from " << lvertex[i1].index << " to " << lvertex[vertex_to_eliminate].index << ")\n";
               print_Graph(model_graph);
               system("pause");
-              exit( -1);
+              exit(EXIT_FAILURE);
             }
 #ifdef SIMPLIFYS
           nb_free++;
@@ -1151,7 +1151,7 @@ SymbolicGaussElimination::Vertex_Elimination(t_model_graph* model_graph, int pos
               cout << "error: Model_Graph not correctly filled in in_degree (edge from " << lvertex[vertex_to_eliminate].index << " to " << lvertex[j1].index << ")\n";
               print_Graph(model_graph);
               system("pause");
-              exit( -1);
+              exit(EXIT_FAILURE);
             }
 #ifdef SIMPLIFYS
           set_free_u_list(lvertex[j1].in_degree_edge[to_add].u_count);
@@ -1193,7 +1193,7 @@ SymbolicGaussElimination::Vertex_Elimination(t_model_graph* model_graph, int pos
                           cout << "loop_table_vertex_index[" << k << "]=" << loop_table_vertex_index[k] << " =? model_graph->vertex[" << i1 << "].index=" << model_graph->vertex[i1].index << "\n";
                           k++;
                         }
-                      exit( -1);
+                      exit(EXIT_FAILURE);
                     }
                   curr_u_count = loop_table_u_count[k] ;
                 }
@@ -1361,7 +1361,7 @@ SymbolicGaussElimination::Gaussian_Elimination(t_model_graph* model_graph
   if(!SaveCode.is_open())
     {
       cout << "Error : Can't open file \"" << file_name << ".bin\" for writing\n";
-      exit( -1);
+      exit(EXIT_FAILURE);
     }
 #ifdef PRINT_OUT
   print_Graph(model_graph);
@@ -1674,7 +1674,7 @@ SymbolicGaussElimination::Gaussian_Elimination(t_model_graph* model_graph
   if((nstacked)&&(!nb_last_save_table_y))
     {
       cout << "not synchronized per=" << per << "\n";
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 
 #ifdef PRINT_OUT
diff --git a/VariableTable.cc b/VariableTable.cc
index ccf523fe663c306782bb5d8510b7d57cb12e18a0..d57fcfd655a4a5bbc9fe1c7492fa098bb6d200f4 100644
--- a/VariableTable.cc
+++ b/VariableTable.cc
@@ -80,7 +80,7 @@ VariableTable::addVariable(SymbolType type, int symb_id, int lag) throw (DynJaco
       break;
     default:
       cerr << "VariableTable::addVariable(): forbidden variable type" << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
   return var_id;
 }
diff --git a/macro/MacroDriver.cc b/macro/MacroDriver.cc
index adfc596c14cfe4182d5a68d0524e70fc20fea0a4..b8d6f9d4ecf6a27e280d0f9d2f14451fdfad1f63 100644
--- a/macro/MacroDriver.cc
+++ b/macro/MacroDriver.cc
@@ -43,7 +43,7 @@ MacroDriver::parse(const string &f, ostream &out, bool debug)
   if (in.fail())
     {
       cerr << "ERROR: Could not open file: " << f << endl;
-      exit(-1);
+      exit(EXIT_FAILURE);
     }
 
   lexer = new MacroFlex(&in, &out);
@@ -60,7 +60,7 @@ void
 MacroDriver::error(const Macro::parser::location_type &l, const string &m) const
 {
   cerr << "ERROR in macro-processor: " << l << ": " << m << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 void
diff --git a/macro/MacroFlex.ll b/macro/MacroFlex.ll
index df7e1c5fecac77c7183586f3e4e0aef78d73e06a..d74ab0640ab36c2d9a55acd588e315177cea930a 100644
--- a/macro/MacroFlex.ll
+++ b/macro/MacroFlex.ll
@@ -408,7 +408,7 @@ int
 MacroFlexLexer::yylex()
 {
   cerr << "MacroFlexLexer::yylex() has been called, that should never happen!" << endl;
-  exit(-1);
+  exit(EXIT_FAILURE);
 }
 
 /*