--- setup.py
+++ setup.py                
@@ -105,7 +105,7 @@
                     'macros': stan_macros})
 
 ## extensions
-extensions_extra_compile_args = ['-O0', '-ftemplate-depth-256']
+extensions_extra_compile_args = ['/EHsc', '/Ox', '-DBOOST_DATE_TIME_NO_LIB']
 
 stanc_sources = [
     "pystan/stan/src/stan/gm/grammars/var_decls_grammar_inst.cpp",

--- pystan\model.py
+++ pystan\model.py
@@ -279,7 +280,7 @@
             s = template.safe_substitute(model_cppname=self.model_cppname)
             outfile.write(s)
 
-        extra_compile_args = ['-O3', '-ftemplate-depth-256']
+        extra_compile_args = ['/EHsc', '/Ox', '-DBOOST_DATE_TIME_NO_LIB']
         distutils.log.set_verbosity(verbose)
         extension = Extension(name=module_name,
                               language="c++",

--- pystan\stan\src\stan\gm\grammars\functions_grammar_def.hpp
+++ pystan\stan\src\stan\gm\grammars\functions_grammar_def.hpp
@@ -126,7 +126,7 @@
       static bool fun_exists(const std::set<std::pair<std::string,
                                                       function_signature_t> >& existing,
                              const std::pair<std::string,function_signature_t>& name_sig) {
-        for (std::set<std::pair<std::string, function_signature_t> >::iterator it 
+        for (std::set<std::pair<std::string, function_signature_t> >::const_iterator it
                = existing.begin();
              it != existing.end();
              ++it)

--- setup.py
+++ setup.py
@@ -119,7 +119,7 @@ libstan = ('stan', {'sources': libstan_sources,
                     'macros': stan_macros})
 
 ## extensions
-extensions_extra_compile_args = ['-O0', '-ftemplate-depth-256']
+extensions_extra_compile_args = ['/EHsc', '/Ox', '-DBOOST_DATE_TIME_NO_LIB']
 
 stanc_sources = [
     "pystan/stan/src/stan/gm/ast_def.cpp",                                    

--- pystan\model.py
+++ pystan\model.py
@@ -279,7 +280,7 @@
             s = template.safe_substitute(model_cppname=self.model_cppname)
             outfile.write(s)
 
-        extra_compile_args = ['-O3', '-ftemplate-depth-256']
+        extra_compile_args = ['/EHsc', '/Ox', '-DBOOST_DATE_TIME_NO_LIB']
         distutils.log.set_verbosity(verbose)
         extension = Extension(name=module_name,
                               language="c++",

Update windows patch for pystan
Update windows patch for pystan
