natelust/least_asymmetry

`initmake_asym` flags an error -- fix provided in text

Closed this issue · 0 comments

Hi Nate,

Your "make_asym.c" flags an error when I try to run "python setup.py install" or "./build.sh" (almost the same thing).

The error is:
"""
make_asym.c:139:3: error: void function 'initmake_asym' should not return a value [-Wreturn-type]
return Py_InitModule("make_asym", make_asym_methods);
"""

So I changed the function slightly to the following, and now it works without a hitch.

void
initmake_asym(void)
{
Py_InitModule("make_asym", make_asym_methods);
import_array();
}


I found this code snippet elsewhere that led me to the answer. It involved creating a macro for the condition "python3" vs "python2" situation. Therefore, the code that I am actually using looks like this:

# if PY_MAJOR_VERSION >= 3
# define NUMPY_IMPORT_ARRAY_RETURN_TYPE int
# else
# define NUMPY_IMPORT_ARRAY_RETURN_TYPE void
# endif

NUMPY_IMPORT_ARRAY_RETURN_TYPE
initmake_asym(void)
{
  Py_InitModule("make_asym", make_asym_methods);
  import_array();
}