Cython没有识别c ++ 11命令

The*_*ude 9 c++ python cython c++11

我用Python包装一个C++类,我无法使用Cython模块编译任何C++ 11特性.

单独编译C++时,一切都可以编译好.但是当我运行下面的setup.py时:

setup(
    ext_modules = cythonize(
       "marketdata.pyx",            # our Cython source
       sources=["cpp/OBwrapper.cpp, cpp/OrderBook/orderbook.h, cpp/OrderBook/orderbook.cpp"],  # additional source file(s)
       language="c++",             # generate C++ code
       extra_compile_args=["-std=c++11"]
    ))
Run Code Online (Sandbox Code Playgroud)

在我的.pyx文件头中:

# distutils: language = c++
# distutils: sources = cpp/OBwrapper.cpp cpp/OrderBook/orderbook.cpp
Run Code Online (Sandbox Code Playgroud)

我得到了很多错误,这些错误与他们没有识别c ++ 11命令有关,比如'auto'.

例如:

cpp/OrderBook/orderbook.cpp(168) : error C2065: 'nullptr' : undeclared identifier
Run Code Online (Sandbox Code Playgroud)

我怎样才能让它发挥作用?

Mes*_*ssa 5

尝试使用Extension:setup(ext_modules=cythonize([Extension(...)], ...).

setup.py对我有用(在Debian Linux上):

from setuptools import setup, find_packages, Extension
from Cython.Build import cythonize
from glob import glob

extensions = [
    Extension(
        'my_proj.cython.hello',
        glob('my_proj/cython/*.pyx')
        + glob('my_proj/cython/*.cxx'),
        extra_compile_args=["-std=c++14"])
]

setup(
    name='my-proj',
    packages=find_packages(exclude=['doc', 'tests']),
    ext_modules=cythonize(extensions))
Run Code Online (Sandbox Code Playgroud)