mehmet.ali.anil
mehmet.ali.anil

Reputation: 525

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!

Upvotes: 1

Views: 201

Answers (1)

Justin Peel
Justin Peel

Reputation: 47082

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.

Upvotes: 1

Related Questions