Python for Windows hang while calling a function of MinGW-w64 compiled library
<p>I'm using ctypes to call a function of a MinGW-w64 compiled library.</p>

<p>C code:</p>

<pre><code>#include &lt;stdio.h&gt;

int hello()
{
    printf("Hello world!\n");
    return 233;
}
</code></pre>

<p>Python Code:</p>

<pre><code>from ctypes import *
lib = CDLL("a.dll")
hello = lib.hello
hello.restype = c_int
hello()
</code></pre>

<p>Compile C code with gcc in MinGW-w64:</p>

<pre><code>gcc tdll.c -shared -o a.dll
</code></pre>

<p>Then run python code in Python for Windows 3.5.2, python hangs on <strong>hello()</strong> with 100% cpu usage.<br>
Then I've tried running the python code in Python for MinGW 3.4.3(installed from msys2 repo), it's no problem.</p>

<p>So What's wrong with my code? How can I workaround it?</p>

<p>Use 'x86_64-w64-mingw32-gcc' or 'i686-w64-mingw32-gcc' instead of 'gcc' in msys!</p>

<p>The 'gcc' command calls x86_64-pc-msys-gcc.</p>

python c mingw ctypes msys