您当前的位置: 首页 >  ar

柳鲲鹏

暂无认证

  • 0浏览

    0关注

    4642博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

柳鲲鹏 发布时间:2019-01-21 14:51:03 ,浏览量:0

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

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

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

关注
打赏
1665724893
查看更多评论
立即登录/注册

微信扫码登录

0.0531s