全网首发:warning: #warning “Using deprecated NumPy API, disable it by “ “#defining NPY_NO_DEPRECATED_API

  吾编译代码,尽可能要求去掉警告.今天编译注意到有这样一个:

In file included from /usr/include/python2.7/numpy/ndarraytypes.h:1777:0,
                 from /usr/include/python2.7/numpy/ndarrayobject.h:18,
                 from /usr/include/python2.7/numpy/arrayobject.h:4,
                 from gh_python.h:30,
                 from gh_python.cpp:1:
/usr/include/python2.7/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it by " \

  这个警告到处都有,应该去掉,这样编译时很清爽.先从网上搜索了一下,没找到有效的解决办法(都说是要安装什么,安装了其实没用).怎么办?

  吾打开ndarraytypes.h:

/*
 * Use the keyword NPY_DEPRECATED_INCLUDES to ensure that the header files
 * npy_*_*_deprecated_api.h are only included from here and nowhere else.
 */
#ifdef NPY_DEPRECATED_INCLUDES
#error "Do not use the reserved keyword NPY_DEPRECATED_INCLUDES."
#endif
#define NPY_DEPRECATED_INCLUDES
#if !defined(NPY_NO_DEPRECATED_API) || \
    (NPY_NO_DEPRECATED_API < NPY_1_7_API_VERSION)
#include "npy_1_7_deprecated_api.h"
#endif

  先定义了一个NPY_DEPRECATED_INCLUDES,被警告.

  于是定义了#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION,警告消失.

 

  希望能给同样要求的朋友,带来一点帮助.

 

后来在github上有人问这个总是,吾提供了本博文:

https://github.com/scipy/scipy/issues/5889#issuecomment-698615330

有人回复:

Pass define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")] as an option to the distutils.extension.Extension constructor in your setup.py

吾觉得还是直接定义的好。

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

柳鲲鹏

能给阁下一点帮助,非常荣幸

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值