如何用distutils指定C ++ 11? [英] How to specify C++11 with distutils?
问题描述
我有一个模块,需要使用C ++ 11进行编译。在GCC和Clang上,这意味着 std = c ++ 11
开关,或 std = c ++ 0x
较旧的编译器。
I have a module that needs to be compiled with C++11. On GCC and Clang, that means a std=c++11
switch, or std=c++0x
on older compilers.
此开关未编译Python,因此Distutils在编译模块时不将其包括在内。
Python is not compiled with this switch so Distutils doesn't include it when compiling modules.
用distutils编译C ++ 11代码的首选方法是什么?
What is the preferred way to compile C++11 code with distutils?
推荐答案
您可以使用 distutils.core.Extension
的> extra_compile_args 参数:
You can use the extra_compile_args
parameter of distutils.core.Extension
:
ext = Extension('foo', sources=[....],
libraries=[....],
extra_compile_args=['-std=c++11'],
....)
请注意,这完全取决于平台。它甚至在某些旧版本的gcc和clang上也无法使用。
Note that this is completely platform dependent. It won't even work on some older versions of gcc and clang.
这篇关于如何用distutils指定C ++ 11?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!