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

简介: 全网首发: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

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

目录
相关文章
|
4月前
|
API
【Azure API 管理】解决API Management添加AAD Group时遇见的 Failed to query Azure Active Directory graph due to error 错误
【Azure API 管理】解决API Management添加AAD Group时遇见的 Failed to query Azure Active Directory graph due to error 错误
|
4月前
|
存储 API
【Azure API 管理】为调用APIM的请求启用Trace -- 调试APIM Policy的利器
【Azure API 管理】为调用APIM的请求启用Trace -- 调试APIM Policy的利器
|
4月前
|
XML 缓存 API
【Azure API 管理】使用APIM进行XML内容读取时遇见的诡异错误 Expression evaluation failed. Object reference not set to an instance of an object.
【Azure API 管理】使用APIM进行XML内容读取时遇见的诡异错误 Expression evaluation failed. Object reference not set to an instance of an object.
|
小程序 JavaScript API
Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ?
Unparenthesized `a ? b : c ? d : e` is deprecated. Use either `(a ? b : c) ? d : e` or `a ? b : (c ?
826 0
|
7月前
|
API Android开发
Android Framework增加API 报错 Missing nullability on parameter
Android Framework增加API 报错 Missing nullability on parameter
345 1
|
7月前
|
网络协议 关系型数据库 MySQL
Open Source Instant Messaging (IM) Project OpenIM Source Code
Open Source Instant Messaging (IM) Project OpenIM Source Code
97 0
jpa中PageRequest @Deprecated和Sort @Deprecated的最新使用方法
jpa中PageRequest @Deprecated和Sort @Deprecated的最新使用方法
|
存储 JSON 缓存
Elasitcsearch High Level Rest Client学习笔记(二) 基础API - 木子H的个人空间 - OSCHINA
Elasitcsearch High Level Rest Client学习笔记(二) 基础API - 木子H的个人空间 - OSCHINA
151 0
|
Cloud Native
Open Policy Agent (OPA) 【3】实战
Open Policy Agent (OPA) 【3】实战
Open Policy Agent (OPA) 【3】实战