swig generated code, generating illegal storage class for python wrapper of C++ API <p>I'm trying to take the approach of using swig with the main header file. It seems like swig will work doing this, but I've run into some problems. I asked a first question about it <a href="http://stackoverflow.com/questions/13581600/compiling-swig-extension-with-coledatetime-for-python">here on stackoverflow</a> and while I haven't yet been successful, I've made enough progress to feel encouraged to continue...</p> <p>So now, here's my interface file:</p> <pre><code>/* File : myAPI.i */ %module myAPI %{ #include "stdafx.h" #include &lt;boost/algorithm/string.hpp&gt; ... many other includes ... #include "myAPI.h" #include &lt;boost/algorithm/string/predicate.hpp&gt; #include &lt;boost/filesystem/path.hpp&gt; #include &lt;boost/filesystem/operations.hpp&gt; using boost::format; using namespace std; using namespace boost::algorithm; using namespace boost::serialization; %} /* Let's just grab the original header file here */ %include "myAPI.h" </code></pre> <p>As far as I can tell swig runs just fine. However, in the generated code it produces numerous definitions like this one:</p> <pre><code>SWIGINTERN int Swig_var_ModState_set(PyObject *_val) { { void *argp = 0; int res = SWIG_ConvertPtr(_val, &amp;argp, SWIGTYPE_p_MY_API, 0 | 0); if (!SWIG_IsOK(res)) { SWIG_exception_fail(SWIG_ArgError(res), "in variable '""ModState""' of type '""MY_API""'"); } if (!argp) { SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in variable '""ModState""' of type '""MY_API""'"); } else { MY_API * temp; temp = reinterpret_cast&lt; MY_API * &gt;(argp); ModState = *temp; if (SWIG_IsNewObj(res)) delete temp; } } return 0; fail: return 1; } </code></pre> <p>Visual Studio 2010 complains with an error for each of these code blocks. The error is based on the <code>temp</code> var:</p> <pre><code>2&gt;c:\svn\myapi\myapi_wrap.cxx(3109): error C2071: 'temp' : illegal storage class </code></pre> <p>I tried just to add a global declaration of this variable as an int to the swig generated _wrap.cxx file, but it didn't not work. (clearly a naive approach...).</p> <p>Does anyone have some insight as to what I need to do to avoid this error?</p> <p>Thanks in advance! </p>