title: How does import_array in numpy C API work?
body: <p>I am trying to convert a c-style array in c++ to a numpy array and ran into problems when trying to use the "PyArray_SimpleNewFromData" function. It turns out I need to call </p>
  
  <pre><code>import_array()
  </code></pre>
  
  <p>Though I do not understand how to call this function. Whenever I try calling it I get compiler error which I do not manage to understand. For instance writing the following simple script:</p>
  
  <pre><code>#include &lt;Python.h&gt;
  #include &lt;numpy/arrayobject.h&gt;
  
  int main(){
      Py_Initialize();
      import_array();
      Py_Finalize();
      return 0;
  }
  </code></pre>
  
  <p>produces the compiler error </p>
  
  <blockquote>
    <p>error: return-statement with no value, in function returning 'int' [-fpermissive]
    import_array();</p>
  </blockquote>
  
  <p>I looked at several examples, such as :</p>
  
  <p><a href="https://stackoverflow.com/questions/7730717/numpy-c-api-example-gives-a-segfault/7732174#7732174">Numpy C-Api example gives a SegFault</a></p>
  
  <p><a href="https://stackoverflow.com/questions/30357115/pyarray-simplenewfromdata-example">PyArray_SimpleNewFromData example</a></p>
  
  <p><a href="https://codereview.stackexchange.com/questions/92266/sending-a-c-array-to-python-numpy-and-back">https://codereview.stackexchange.com/questions/92266/sending-a-c-array-to-python-numpy-and-back</a></p>
  
  <p><a href="https://stackoverflow.com/questions/32899621/numpy-capi-error-with-import-array-when-compiling-multiple-modules">Numpy/CAPI error with import_array() when compiling multiple modules</a></p>
  
  <p>But whatever I try (even when seemingly following those examples) I seem to run into the compiler error above. What am I missing or doing wrong? An explanation on how the import_array() function should be called would be very welcome. Thanks for the help!</p>
  
  <p>Update:</p>
  
  <p>I am using python 2.7.11, and I think it might be related to what is discussed here :</p>
  
  <p><a href="https://github.com/clemenscorny/brisk/issues/3" rel="nofollow noreferrer">https://github.com/clemenscorny/brisk/issues/3</a></p>
  
  <p>but I still have no idea how to fix it.</p>