cc1plus: warning: command line option “-Wstrict-prototypes” is valid for Ada/C/ObjC but not for C++

后端 未结 7 781
日久生厌
日久生厌 2020-12-13 12:40

I am building a C++ extension for use in Python. I am seeing this warning being generated during the compilation process - when a type:

python setup.py build         


        
7条回答
  •  天涯浪人
    2020-12-13 13:18

    Removing -Wstrict-prototypes from the OPT environment variable has no effect. What works is to subclass build_ext as follows:

    from distutils.command.build_ext import build_ext
    from distutils.sysconfig import customize_compiler
    
    class my_build_ext(build_ext):
        def build_extensions(self):
            customize_compiler(self.compiler)
            try:
                self.compiler.compiler_so.remove("-Wstrict-prototypes")
            except (AttributeError, ValueError):
                pass
            build_ext.build_extensions(self)
    

    and then use my_build_ext inside the setup function:

    setup(cmdclass = {'build_ext': my_build_ext})
    

提交回复
热议问题