diff --git a/others/C/dynare_driver.h b/others/C/dynare_driver.h
new file mode 100644
index 0000000000000000000000000000000000000000..dfaa7c60a9bc72c9bc928c1aa4bb78a4e2bf1e80
--- /dev/null
+++ b/others/C/dynare_driver.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2011-2012 Houtan Bastani, Daniel Waggoner, Tao Zha
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This code is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * More information is available at <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _DYNARE_C_DRIVER_H
+#define _DYNARE_C_DRIVER_H
+
+#include <cstdlib>
+#include <vector>
+#include <string>
+#include <map>
+#include <limits>
+
+using namespace std;
+
+struct aux_vars_t {
+  int endo_index, type, orig_index, orig_lead_lag;
+} ;
+
+#endif // ! _DYNARE_C_DRIVER_H
diff --git a/preprocessor/DynamicModel.cc b/preprocessor/DynamicModel.cc
index b34057b0ebd816fd02cde9d888f75a5db92d8db8..415b9b27f6bdf67801d8a83f16716c6a6fa7bf0a 100644
--- a/preprocessor/DynamicModel.cc
+++ b/preprocessor/DynamicModel.cc
@@ -2958,6 +2958,99 @@ DynamicModel::writeOutput(ostream &output, const string &basename, bool block_de
 
 void
 DynamicModel::writeCOutput(ostream &output, const string &basename, bool block_decomposition, bool byte_code, bool use_dll, int order, bool estimation_present) const
+{
+  int lag_presence[3];
+  // Loop on endogenous variables
+  vector<int> zeta_back, zeta_mixed, zeta_fwrd, zeta_static;
+  for (int endoID = 0; endoID < symbol_table.endo_nbr(); endoID++)
+    {
+      int varID;
+      // Loop on periods
+      for (int lag = 0; lag <= 2; lag++)
+	{
+	  lag_presence[lag] = 1;
+          try
+            {
+              varID = getDerivID(symbol_table.getID(eEndogenous, endoID), lag-1);
+            }
+          catch (UnknownDerivIDException &e)
+            {
+	      lag_presence[lag] = 0;
+            }
+        }
+      if (lag_presence[0] == 1)
+	if (lag_presence[2] == 1)
+	  zeta_mixed.push_back(endoID);
+	else
+	  zeta_back.push_back(endoID);
+      else if (lag_presence[2] == 1)
+	zeta_fwrd.push_back(endoID);
+      else
+	zeta_static.push_back(endoID);
+      
+    }
+  output << "nstatic = " << zeta_static.size() << ";" << endl
+         << "nfwrd   = " << zeta_fwrd.size() << ";" << endl
+         << "nback   = " << zeta_back.size() << ";" << endl
+         << "nmixed  = " << zeta_mixed.size() << ";" << endl;
+  output << "zeta_static[" << zeta_static.size() << "] = {";
+  for (vector<int>::iterator i = zeta_static.begin(); i != zeta_static.end(); ++i)
+    {
+      if ( i != zeta_static.begin() )
+	output << ",";
+      output << *i;
+    }
+  output << "};" << endl;
+
+  output << "zeta_back[" << zeta_back.size() << "] = {";
+  for (vector<int>::iterator i = zeta_back.begin(); i != zeta_back.end(); ++i)
+    {
+      if ( i != zeta_back.begin() )
+	output << ",";
+      output << *i;
+    }
+  output << "};" << endl;
+
+  output << "zeta_fwrd[" << zeta_fwrd.size() << "] = {";
+  for (vector<int>::iterator i = zeta_fwrd.begin(); i != zeta_fwrd.end(); ++i)
+    {
+      if ( i != zeta_fwrd.begin() )
+	output << ",";
+      output << *i;
+    }
+  output << "};" << endl;
+
+  output << "zeta_mixed[" << zeta_mixed.size() << "] = {";
+  for (vector<int>::iterator i = zeta_mixed.begin(); i != zeta_mixed.end(); ++i)
+    {
+      if ( i != zeta_mixed.begin() )
+	output << ",";
+      output << *i;
+    }
+  output << "};" << endl;
+
+  // Write number of non-zero derivatives
+  // Use -1 if the derivatives have not been computed
+  output << "int *NNZDerivatives[3] = {";
+  switch (order)
+    {
+    case 0:
+      output << NNZDerivativs[0] << ",-1,-1};" << endl;
+      break;
+    case 1:
+      output << NNZDerivativs[0] << "," << NNZDerivatives[1] << ",-1};" << endl;
+      break;
+    case 2:
+      output << NNZDerivativs[0] << "," << NNZDerivatives[1] << "," << NNZDerivatives[2] << "};" << endl;
+      break;
+    default:
+	cerr << "Order larger than 3 not implemented" << endl;
+	exit(EXIT_FAILURE);
+    }
+}
+
+void
+DynamicModel::writeCCOutput(ostream &output, const string &basename, bool block_decomposition, bool byte_code, bool use_dll, int order, bool estimation_present) const
 {
   int lag_presence[3];
   // Loop on endogenous variables
@@ -4339,9 +4432,9 @@ DynamicModel::dynamicOnlyEquationsNbr() const
 }
 
 void
-DynamicModel::writeFirstDerivativesCC(const string &basename, bool cuda) const
+DynamicModel::writeFirstDerivativesC(const string &basename, bool cuda) const
 {
-  string filename = basename + "_first_derivatives.cc";
+  string filename = basename + "_first_derivatives.c";
   ofstream mDynamicModelFile, mDynamicMexFile;
 
   mDynamicModelFile.open(filename.c_str(), ios::out | ios::binary);
@@ -4396,10 +4489,10 @@ DynamicModel::writeFirstDerivativesCC(const string &basename, bool cuda) const
 
 // using compressed sparse row format (CSR)
 void
-DynamicModel::writeSecondDerivativesCC_csr(const string &basename, bool cuda) const
+DynamicModel::writeSecondDerivativesC_csr(const string &basename, bool cuda) const
 {
 
-  string filename = basename + "_second_derivatives.cc";
+  string filename = basename + "_second_derivatives.c";
   ofstream mDynamicModelFile, mDynamicMexFile;
 
   mDynamicModelFile.open(filename.c_str(), ios::out | ios::binary);
@@ -4490,9 +4583,9 @@ DynamicModel::writeSecondDerivativesCC_csr(const string &basename, bool cuda) co
 }
 
 void
-DynamicModel::writeThirdDerivativesCC_csr(const string &basename, bool cuda) const
+DynamicModel::writeThirdDerivativesC_csr(const string &basename, bool cuda) const
 {
-  string filename = basename + "_third_derivatives.cc";
+  string filename = basename + "_third_derivatives.c";
   ofstream mDynamicModelFile, mDynamicMexFile;
 
   mDynamicModelFile.open(filename.c_str(), ios::out | ios::binary);
diff --git a/preprocessor/DynamicModel.hh b/preprocessor/DynamicModel.hh
index 8de6bd3926a74e1990a8a625f352bcf3808778f5..e1ee490bb130d91afa51119ec5e9d03bdf7e9c4b 100644
--- a/preprocessor/DynamicModel.hh
+++ b/preprocessor/DynamicModel.hh
@@ -215,6 +215,8 @@ public:
   void writeOutput(ostream &output, const string &basename, bool block, bool byte_code, bool use_dll, int order, bool estimation_present) const;
   //! Writes model initialization and lead/lag incidence matrix to C output
   void writeCOutput(ostream &output, const string &basename, bool block, bool byte_code, bool use_dll, int order, bool estimation_present) const;
+  //! Writes model initialization and lead/lag incidence matrix to Cpp output
+  void writeCCOutput(ostream &output, const string &basename, bool block, bool byte_code, bool use_dll, int order, bool estimation_present) const;
 
   //! Adds informations for simulation in a binary file
   void Write_Inf_To_Bin_File_Block(const string &dynamic_basename, const string &bin_basename,
@@ -224,11 +226,11 @@ public:
   //! Writes file containing parameters derivatives
   void writeParamsDerivativesFile(const string &basename) const;
   //! Writes CC file containing first order derivatives of model evaluated at steady state
-  void writeFirstDerivativesCC(const string &basename, bool cuda) const;
+  void writeFirstDerivativesC(const string &basename, bool cuda) const;
   //! Writes CC file containing second order derivatives of model evaluated at steady state (compressed sparse column)
-  void writeSecondDerivativesCC_csr(const string &basename, bool cuda) const;
+  void writeSecondDerivativesC_csr(const string &basename, bool cuda) const;
   //! Writes CC file containing third order derivatives of model evaluated at steady state (compressed sparse column)
-  void writeThirdDerivativesCC_csr(const string &basename, bool cuda) const;
+  void writeThirdDerivativesC_csr(const string &basename, bool cuda) const;
   //! Converts to static model (only the equations)
   /*! It assumes that the static model given in argument has just been allocated */
   void toStatic(StaticModel &static_model) const;
diff --git a/preprocessor/ModFile.cc b/preprocessor/ModFile.cc
index fd5b471534b249468121ac386f04bc77de482a9c..7e73f550e89bb2841fb9540d3eb9f8514b433709 100644
--- a/preprocessor/ModFile.cc
+++ b/preprocessor/ModFile.cc
@@ -814,6 +814,82 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool no_log, b
   cout << "done" << endl;
 }
 
+void
+ModFile::writeModelC(const string &basename, bool cuda) const
+{
+  string filename = basename + ".c";
+
+  ofstream mDriverCFile;
+  mDriverCFile.open(filename.c_str(), ios::out | ios::binary);
+  if (!mDriverCFile.is_open())
+    {
+      cerr << "Error: Can't open file " << filename << " for writing" << endl;
+      exit(EXIT_FAILURE);
+    }
+
+  mDriverCFile << "/*" << endl
+               << " * " << filename << " : Driver file for Dynare C code" << endl
+               << " *" << endl
+               << " * Warning : this file is generated automatically by Dynare" << endl
+               << " *           from model file (.mod)" << endl
+               << " */" << endl
+               << endl
+               << "#include \"dynare_driver.h\"" << endl
+               << endl
+               << "struct" << endl
+               << "{" << endl;
+
+  // Write basic info
+  symbol_table.writeCOutput(mDriverCFile);
+
+  mDriverCFile << endl << "params.resize(param_nbr);" << endl;
+
+  if (dynamic_model.equation_number() > 0)
+    {
+      dynamic_model.writeCOutput(mDriverCFile, basename, block, byte_code, use_dll, mod_file_struct.order_option, mod_file_struct.estimation_present);
+      //      if (!no_static)
+      //        static_model.writeCOutput(mOutputFile, block);
+    }
+
+  // Print statements
+  for (vector<Statement *>::const_iterator it = statements.begin();
+       it != statements.end(); it++)
+      (*it)->writeCOutput(mDriverCFile, basename);
+
+  mDriverCFile << "} DynareInfo;" << endl;
+  mDriverCFile.close();
+
+  // Write informational m file
+  ofstream mOutputFile;
+
+  if (basename.size())
+    {
+      string fname(basename);
+      fname += ".m";
+      mOutputFile.open(fname.c_str(), ios::out | ios::binary);
+      if (!mOutputFile.is_open())
+        {
+          cerr << "ERROR: Can't open file " << fname
+               << " for writing" << endl;
+          exit(EXIT_FAILURE);
+        }
+    }
+  else
+    {
+      cerr << "ERROR: Missing file name" << endl;
+      exit(EXIT_FAILURE);
+    }
+
+  mOutputFile << "%" << endl
+              << "% Status : informational m file" << endl
+              << "%" << endl
+              << "% Warning : this file is generated automatically by Dynare" << endl
+              << "%           from model file (.mod)" << endl << endl
+              << "disp('The following C file was successfully created:');" << endl
+              << "ls preprocessorOutput.c" << endl << endl;
+  mOutputFile.close();
+}
+
 void
 ModFile::writeModelCC(const string &basename, bool cuda) const
 {
@@ -828,7 +904,7 @@ ModFile::writeModelCC(const string &basename, bool cuda) const
     }
 
   mDriverCFile << "/*" << endl
-               << " * " << filename << " : Driver file for MS-DSGE code" << endl
+               << " * " << filename << " : Driver file for Dynare C++ code" << endl
                << " *" << endl
                << " * Warning : this file is generated automatically by Dynare" << endl
                << " *           from model file (.mod)" << endl
@@ -840,7 +916,7 @@ ModFile::writeModelCC(const string &basename, bool cuda) const
                << "{" << endl;
 
   // Write basic info
-  symbol_table.writeCOutput(mDriverCFile);
+  symbol_table.writeCCOutput(mDriverCFile);
 
   mDriverCFile << endl << "params.resize(param_nbr);" << endl;
 
@@ -856,7 +932,7 @@ ModFile::writeModelCC(const string &basename, bool cuda) const
        it != statements.end(); it++)
       (*it)->writeCOutput(mDriverCFile, basename);
 
-  mDriverCFile << "}" << endl;
+  mDriverCFile << "};" << endl;
   mDriverCFile.close();
 
   // Write informational m file
@@ -885,7 +961,7 @@ ModFile::writeModelCC(const string &basename, bool cuda) const
               << "%" << endl
               << "% Warning : this file is generated automatically by Dynare" << endl
               << "%           from model file (.mod)" << endl << endl
-              << "disp('The following C file was successfully created:');" << endl
+              << "disp('The following C++ file was successfully created:');" << endl
               << "ls preprocessorOutput.cc" << endl << endl;
   mOutputFile.close();
 }
@@ -893,8 +969,8 @@ ModFile::writeModelCC(const string &basename, bool cuda) const
 void
 ModFile::writeExternalFiles(const string &basename, FileOutputType output, bool cuda) const
 {
-  writeModelCC(basename, cuda);
-  steady_state_model.writeSteadyStateFileCC(basename, mod_file_struct.ramsey_model_present, cuda);
+  writeModelC(basename, cuda);
+  steady_state_model.writeSteadyStateFileC(basename, mod_file_struct.ramsey_model_present, cuda);
 
   dynamic_model.writeDynamicFile(basename, block, byte_code, use_dll, mod_file_struct.order_option);
 
@@ -903,18 +979,18 @@ ModFile::writeExternalFiles(const string &basename, FileOutputType output, bool
 
 
   //  static_model.writeStaticCFile(basename, block, byte_code, use_dll);
-  //  static_model.writeParamsDerivativesFileCC(basename, cuda);
-  //  static_model.writeAuxVarInitvalCC(mOutputFile, oMatlabOutsideModel, cuda);
+  //  static_model.writeParamsDerivativesFileC(basename, cuda);
+  //  static_model.writeAuxVarInitvalC(mOutputFile, oMatlabOutsideModel, cuda);
 
-  // dynamic_model.writeResidualsCC(basename, cuda);
-  // dynamic_model.writeParamsDerivativesFileCC(basename, cuda);
-  dynamic_model.writeFirstDerivativesCC(basename, cuda);
+  // dynamic_model.writeResidualsC(basename, cuda);
+  // dynamic_model.writeParamsDerivativesFileC(basename, cuda);
+  dynamic_model.writeFirstDerivativesC(basename, cuda);
   
   if (output == second)
-    dynamic_model.writeSecondDerivativesCC_csr(basename, cuda);
+    dynamic_model.writeSecondDerivativesC_csr(basename, cuda);
   else if (output == third)
     {
-        dynamic_model.writeSecondDerivativesCC_csr(basename, cuda);
-  	dynamic_model.writeThirdDerivativesCC_csr(basename, cuda);
+        dynamic_model.writeSecondDerivativesC_csr(basename, cuda);
+  	dynamic_model.writeThirdDerivativesC_csr(basename, cuda);
     }
 }
diff --git a/preprocessor/ModFile.hh b/preprocessor/ModFile.hh
index aca8ef9d1d618c8205a0d2760b85bcd99ba4b7fd..9885c6e6deb883acb4cd59096ad4aee638afe776 100644
--- a/preprocessor/ModFile.hh
+++ b/preprocessor/ModFile.hh
@@ -140,7 +140,7 @@ public:
                         ) const;
   //! Writes C output files only => No further Matlab processing
   void writeCOutputFiles(const string &basename) const;
-  void writeModelCC(const string &basename, bool cuda) const;
+  void writeModelC(const string &basename, bool cuda) const;
   void writeExternalFiles(const string &basename, FileOutputType output, bool cuda) const;
 };
 
diff --git a/preprocessor/SteadyStateModel.cc b/preprocessor/SteadyStateModel.cc
index f1069642b43f050bb1f0ecebd82523bfff59899e..1c590a98aa3c76b8ce74ddc5375561d53fc6255f 100644
--- a/preprocessor/SteadyStateModel.cc
+++ b/preprocessor/SteadyStateModel.cc
@@ -153,9 +153,9 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool ramsey_model
 }
 
 void
-SteadyStateModel::writeSteadyStateFileCC(const string &basename, bool ramsey_model, bool cuda) const
+SteadyStateModel::writeSteadyStateFileC(const string &basename, bool ramsey_model, bool cuda) const
 {
-  string filename = basename + "_steadystate.cc";
+  string filename = basename + "_steadystate.c";
 
   ofstream output;
   output.open(filename.c_str(), ios::out | ios::binary);
diff --git a/preprocessor/SteadyStateModel.hh b/preprocessor/SteadyStateModel.hh
index 817f84f5a86d4aa32d0120387c0807f83ac3bcb7..f8bb051f0320556675ae0564b8fab207a749d57c 100644
--- a/preprocessor/SteadyStateModel.hh
+++ b/preprocessor/SteadyStateModel.hh
@@ -49,7 +49,7 @@ public:
     \param[in] ramsey_model Is there a Ramsey model in the MOD file? If yes, then use the "ys" in argument of the steady state file as initial values
   */
   void writeSteadyStateFile(const string &basename, bool ramsey_model) const;
-  void writeSteadyStateFileCC(const string &basename, bool ramsey_model, bool cuda) const;
+  void writeSteadyStateFileC(const string &basename, bool ramsey_model, bool cuda) const;
 };
 
 #endif
diff --git a/preprocessor/SymbolTable.cc b/preprocessor/SymbolTable.cc
index 0015268433bb5b3f10c31281bf4337bdaa5cfbc3..4e207cfe7e60eca5cdb02990653c6fbecc158726 100644
--- a/preprocessor/SymbolTable.cc
+++ b/preprocessor/SymbolTable.cc
@@ -288,6 +288,103 @@ SymbolTable::writeOutput(ostream &output) const throw (NotYetFrozenException)
 
 void
 SymbolTable::writeCOutput(ostream &output) const throw (NotYetFrozenException)
+{
+  if (!frozen)
+    throw NotYetFrozenException();
+
+  output << endl
+         << "int exo_nbr = " << exo_nbr() << ";" << endl;
+  if (exo_nbr() > 0)
+    {
+      output << "char *exo_names[" << exo_nbr() << "];" << endl;
+      for (int id = 0; id < exo_nbr(); id++)
+	output << "exo_names[" << id << "] = \"" << getName(exo_ids[id]) << "\";" << endl;
+    }
+
+  output << endl
+         << "int exo_det_nbr = " << exo_det_nbr() << ";" << endl;
+  if (exo_det_nbr() > 0)
+    {
+      output << "char *exo_det_names[" << exo_det_nbr() << "];" << endl;
+      for (int id = 0; id < exo_det_nbr(); id++)
+	output << "exo_det_names[" << id << "] = \"" << getName(exo_det_ids[id]) << "\";" << endl;
+    }
+
+  output << endl
+         << "int endo_nbr = " << endo_nbr() << ";" << endl;
+  if (endo_nbr() > 0)
+    {
+      output << "char *endo_names[" << endo_nbr() << "];" << endl;
+      for (int id = 0; id < endo_nbr(); id++)
+	output << "endo_names[" << id << "] = \"" << getName(endo_ids[id]) << "\";" << endl;
+    }
+
+  output << endl
+         << "int param_nbr = " << param_nbr() << ";" << endl;
+  if (param_nbr() > 0)
+    {
+      output << "char *param_names[" << param_nbr() << "];" << endl;
+      for (int id = 0; id < param_nbr(); id++)
+	output << "param_names[" << id << "] = \"" << getName(param_ids[id]) << "\";" << endl;
+    }
+
+  // Write the auxiliary variable table
+  output << "int aux_var_nbr = " << aux_vars.size() << ";" << endl;
+  if (aux_vars.size() > 0)
+    {
+      output << "struct aux_vars_t *av[" << aux_vars.size() << "];" << endl;
+      for (int i = 0; i < (int) aux_vars.size(); i++)
+	{
+	  output << "av[" << i << "].endo_index = " << getTypeSpecificID(aux_vars[i].get_symb_id()) << ";" << endl
+		 << "av[" << i << "].type = " << aux_vars[i].get_type() << ";" << endl;
+	  switch (aux_vars[i].get_type())
+	    {
+	    case avEndoLead:
+	    case avExoLead:
+	    case avExpectation:
+	    case avMultiplier:
+	    case avDiffForward:
+	      break;
+	    case avEndoLag:
+	    case avExoLag:
+	      output << "av[" << i << "].orig_index = " << getTypeSpecificID(aux_vars[i].get_orig_symb_id()) << ";" << endl
+		     << "av[" << i << "].orig_lead_lag = " << aux_vars[i].get_orig_lead_lag() << ";" << endl;
+	      break;
+	    }
+	}
+    }
+
+  output << "int predeterminedNbr = " << predeterminedNbr() << ";" << endl;
+  if (predeterminedNbr() > 0)
+    {
+      output << "int predetermined_variables[" << predeterminedNbr() << "] = {"; 
+      for (set<int>::const_iterator it = predetermined_variables.begin();
+	   it != predetermined_variables.end(); it++)
+	{
+	  if ( it != predetermined_variables.begin() )
+	    output << ",";
+	  output << getTypeSpecificID(*it);
+	}
+      output << "};" << endl;
+    }
+
+  output << "int observedVariablesNbr = " << observedVariablesNbr() << ";" << endl;
+  if (observedVariablesNbr() > 0)
+    {
+      output << "int varobs[" << observedVariablesNbr() << "] = {";
+      for (vector<int>::const_iterator it = varobs.begin();
+	   it != varobs.end(); it++)
+	{
+	  if ( it != varobs.begin() )
+	    output << ",";
+	  output << getTypeSpecificID(*it);
+	}
+      output  << "};" << endl;
+    }
+}
+
+void
+SymbolTable::writeCCOutput(ostream &output) const throw (NotYetFrozenException)
 {
   if (!frozen)
     throw NotYetFrozenException();
@@ -596,7 +693,7 @@ SymbolTable::getEndogenous() const
 bool
 SymbolTable::isAuxiliaryVariable(int symb_id) const
 {
-  for (int i = 0; i < aux_vars.size(); i++)
+  for (int i = 0; i < (int) aux_vars.size(); i++)
     if (aux_vars[i].get_symb_id() == symb_id)
       return true;
   return false;
diff --git a/preprocessor/SymbolTable.hh b/preprocessor/SymbolTable.hh
index 8e0903e5cab36e0cc06f0938a3f4255841efb2d9..3e4c47e126940efb470002e6a81b597ba22330f8 100644
--- a/preprocessor/SymbolTable.hh
+++ b/preprocessor/SymbolTable.hh
@@ -278,6 +278,8 @@ public:
   void writeOutput(ostream &output) const throw (NotYetFrozenException);
   //! Write C output of this class
   void writeCOutput(ostream &output) const throw (NotYetFrozenException);
+  //! Write CC output of this class
+  void writeCCOutput(ostream &output) const throw (NotYetFrozenException);
   //! Mark a symbol as predetermined variable
   void markPredetermined(int symb_id) throw (UnknownSymbolIDException, FrozenException);
   //! Test if a given symbol is a predetermined variable