According to the Cython documentation ,I write the following cython code as follows:
In [1]:%load_ext Cython
In [2]: %%cython
from libcpp.vector c
As an alternative to @romeric's answer, the documentation for ipython Cython magic suggests using
%%cython --cplus
to turn on C++ mode. Help for the command can also be accessed by running %%cython?
in the IPython console.
Personally I think there's a lot to be said for using the distutils comment approach, since it links the language with the code that requires it.
You need to tell cython
that you are compiling C++
and not C
, through the special comment
# distutils: language = c++
adding this after the %%cython
block will fix your problem.