From bcad0b661cbb676b85ab421787b1f1a51561e196 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Mon, 23 Jul 2012 21:27:40 +0000 Subject: [PATCH] Added workaround for MSVC limitation on number of consecutive loops --- wrap/Module.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wrap/Module.cpp b/wrap/Module.cpp index 8c564e92f..229a9810f 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -558,13 +558,15 @@ void Module::WriteCollectorsAndCleanupFcn(FileWriter& wrapperFile, const std::st const string cppName = cls.qualifiedName("::"); const string collectorType = "Collector_" + matlabUniqueName; const string collectorName = "collector_" + matlabUniqueName; + // The extra curly-braces around the for loops work around a limitation in MSVC (existing + // since 2005!) preventing more than 248 blocks. wrapperFile.oss << - " for(" << collectorType << "::iterator iter = " << collectorName << ".begin();\n" + " { for(" << collectorType << "::iterator iter = " << collectorName << ".begin();\n" " iter != " << collectorName << ".end(); ) {\n" " delete *iter;\n" " " << collectorName << ".erase(iter++);\n" " anyDeleted = true;\n" - " }\n"; + " } }\n"; } wrapperFile.oss << " if(anyDeleted)\n"