summaryrefslogtreecommitdiff
path: root/tests/errors/w_numpy_arr_as_cppvec_ref.pyx
blob: b8dd1f53600fc4f62749fb8b51da98fe31727a22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# mode: error
# tag: cpp, werror, numpy

import numpy as np
cimport numpy as np
from libcpp.vector cimport vector

np.import_array()

cdef extern from *:
    void cpp_function_vector1(vector[int])
    void cpp_function_vector2(vector[int] &)
    void cpp_function_2_vec_refs(vector[int] &, vector[int] &)


def main():
    cdef np.ndarray[int, ndim=1, mode="c"] arr = np.zeros(10, dtype='intc')
    cpp_function_vector1(arr)
    cpp_function_vector2(arr)
    cpp_function_vector2(arr)
    cpp_function_2_vec_refs(arr, arr)

    cdef vector[int] vec
    vec.push_back(0)
    cpp_function_vector2(vec)


_ERRORS = """
19:25: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
20:25: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
21:28: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
21:33: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
"""