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

后端 未结 7 789
日久生厌
日久生厌 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:22

    -Wstrict-prototypes option is read by distutils from /usr/lib/pythonX.Y/config/Makefile as part of OPT variable. It seems hackish, but you can override it by setting os.environ['OPT'] in your setup.py.

    Here is a code that seems not too harmful:

    import os
    from distutils.sysconfig import get_config_vars
    
    (opt,) = get_config_vars('OPT')
    os.environ['OPT'] = " ".join(
        flag for flag in opt.split() if flag != '-Wstrict-prototypes'
    )
    

提交回复
热议问题