Commit b4189182 authored by Sébastien Villemot's avatar Sébastien Villemot

Preprocessor: erase generated steady state file at each run

Since generated and hand written steady state files have the same filename, the
idea is to add a specific header in the generated file so that the preprocessor
can distinguish between the two.

Closes: #224
parent 1aa5efcc
......@@ -450,6 +450,22 @@ ModFile::writeOutputFiles(const string &basename, bool clear_all, bool console,
if (!use_dll)
mOutputFile << "erase_compiled_function('" + basename + "_dynamic');" << endl;
// Erase generated steady state file (see ticket #224)
string steadystatefile = basename + "_steadystate.m";
ifstream in(steadystatefile.c_str(), ios::binary);
if (!in.fail())
{
string line;
getline(in, line);
if (!line.compare(STEADY_STATE_GENERATED_HEADER))
{
in.close();
unlink(steadystatefile.c_str());
}
else
in.close();
}
#if defined(_WIN32) || defined(__CYGWIN32__)
// If using USE_DLL with MSVC, check that the user didn't use a function not supported by MSVC (because MSVC doesn't comply with C99 standard)
if (use_dll && msvc)
......
......@@ -113,7 +113,11 @@ SteadyStateModel::writeSteadyStateFile(const string &basename, bool ramsey_polic
exit(EXIT_FAILURE);
}
output << "function [ys_, check_] = " << basename << "_steadystate(";
/* The following header is used when the preprocessor deletes the old
generated steady state file: it distinguishes this file from a hand
written one (see ticket #224) */
output << STEADY_STATE_GENERATED_HEADER << endl
<< "function [ys_, check_] = " << basename << "_steadystate(";
if (ramsey_policy)
output << "ys_";
else
......
......@@ -23,6 +23,8 @@
#include "DataTree.hh"
#include "StaticModel.hh"
#define STEADY_STATE_GENERATED_HEADER "% Generated file, will be deleted at next run of Dynare"
class SteadyStateModel : public DataTree
{
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment