How to specify C++11 with distutils?

后端 未结 2 1820
[愿得一人]
[愿得一人] 2021-02-04 03:18

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

2条回答
  •  不思量自难忘°
    2021-02-04 03:31

    You can use the extra_compile_args parameter of distutils.core.Extension:

    ext = Extension('foo', sources=[....],
                    libraries=[....], 
                    extra_compile_args=['-std=c++11'],
                    ....)
    

    Note that this is completely platform dependent. It won't even work on some older versions of gcc and clang.

提交回复
热议问题