【发布时间】:2021-10-30 12:41:15
【问题描述】:
我正在尝试在 Cython 中同时编译 C 和 C++ 源代码。这是我目前的设置:
-setup.py
from distutils.core import setup
from Cython.Build import cythonize
from distutils.extension import Extension
import os
language = "c++"
extra_compile_flags = ["-std=c++17"]
os.environ["CC"] = "clang++"
ext_modules = [
Extension(
name="Dummy",
sources=["mydummy.pyx", "source1.cpp","source2.c"],
language=language,
extra_compile_args=extra_compile_flags,
)
]
ext_modules = cythonize(ext_modules)
setup(
name="myapp",
ext_modules=ext_modules,
)
-编译命令:
python3 setup.py build_ext --inplace --verbose
在日志中我收到以下消息:
clang++ -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I. -I/usr/include/python3.6m -I/usr/include/python3.6m -c /path/source2.c -o build/temp.linux-x86_64-3.6/./path/source2.o -std=c++17 -O3
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
编译通过,但警告看起来很讨厌。我怎样才能摆脱它? 天真的解决方案
os.environ["CC"] = "clang"
os.environ["CXX"] = "clang++"
error: invalid argument '-std=c++17' not allowed with 'C' 失败
【问题讨论】:
标签: c++ compiler-errors clang cython clang++