简体   繁体   中英

PyArray_BOOL declaration & working with Numpy array of bools in C extension

I have a NumPy array of bools in my code that I wish to write a C extension to. When I try to get a contiguous array in order to use in my C routine, I use:

arr_mask = (PyArrayObject *)
    PyArray_ContiguousFromObject(mask, PyArray_BOOL, 2, 2);

But I get the compiler error that PyArray_BOOL is not declared.

xor_masking.c:44:40: error: ‘PyArray_BOOL’ undeclared (first use in this function)

Why it is so? Is this type undeclared? If it is so, how can I introduce my array of bools to C?

Thanks!

You need to use NPY_BOOL rather than PyArray_BOOL. Also, you will need to be using the numpy header rather than the numeric header if you are still using the numeric header like in one of your other questions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM