title: Does IPython support ctypes?
body: <p>I am trying to execute C code in IPython (using ctypes), but IPython crashes every time a C function is called.</p>
  <h3>Environment</h3>
  <ul>
  <li>Windows 10 (64bit)</li>
  <li>Python 3.8.5 64bit</li>
  <li>GCC 9.1.0 (tdm-gcc)</li>
  </ul>
  <h3>Minimum working example</h3>
  <p>File <code>test.c</code>:</p>
  <pre class="lang-c prettyprint-override"><code>int func(){
      return 10;
  }
  </code></pre>
  <p>Compile in commandline:</p>
  <pre><code>gcc -shared -o test.dll -fPIC test.c
  </code></pre>
  <p>Start IPython in the same directory, then run:</p>
  <pre><code>In [1]: import ctypes
     ...: lib = ctypes.CDLL(&quot;test.dll&quot;)
     ...: lib.func()
  Out[1]: 10
  </code></pre>
  <p>The output <code>Out[1]</code> is correct, but IPython crashes immediately after <code>Out[1]: 10</code> is printed. (sometimes it crashes before <code>Out[1]: 10</code> is printed)</p>
  <h3>Question</h3>
  <p>Does IPython support ctypes?</p>
  <p>If so, why the aforementioned problem occured?</p>
  <p>If not so, is there a workaround to use ctypes in IPython/Jupyter Notebook?</p>
  <h3>Updates</h3>
  <ul>
  <li>Tried the same code on WSL (on the same machine); IPython did not crash.</li>
  <li>Tried Tim Roberts's solution (changing <code>CDLL</code> to <code>WinDLL</code>; see comments); did not work.</li>
  </ul>
  <h3>Update: problem solved</h3>
  <p>Switched from TDM-GCC to Mingw-w64, and this somehow solves the problem.</p>