c - 警告:函数“timerisset”的隐式声明
问题描述
从较旧的 CentOS 服务器移动到具有相同 GCC 版本的较新服务器会导致编译 C 代码时出现错误,而该错误不会在旧服务器上发生:
interp.c: In function `update_userec':
interp.c:1100: warning: implicit declaration of function `timerisset'
interp.c:1101: warning: implicit declaration of function `timercmp'
interp.c:1101: error: syntax error before '<' token
代码:
if ( !timerisset(&userec->min_time)
|| timercmp(time_used, &userec->min_time, <) )
{
该文件确实在文件顶部有:
#include <time.h>
gcc 版本:
Reading specs from /usr/lib/gcc/x86_64-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,f77 --disable-libgcj --host=x86_64-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-19.el6)
手册页确实提到:
glibc 的功能测试宏要求(参见 feature_test_macros(7)):
All functions shown above: Since glibc 2.19: _DEFAULT_SOURCE Glibc 2.19 and earlier: _BSD_SOURCE
但是定义_DEFAULT_SOURCE
或_BSD_SOURCE
高于该include
线并不能解决任何问题。
解决方案
推荐阅读
- php - 在 PHP 中传递一个值
- python - 导入时找不到模块 PyQt5
- angular - 如何从角度 6 中的 MatTableDataSource 中获取过滤后的记录
- swift - 在父项目中导入桥接头失败
- android - 在 React Native 中配置项目时出现问题
- python - 在 Windows 上安装 geopandas 的问题
- android - 无法连接到 android Studio 上的解析服务器?
- c++ - NodeJS Nan C++ 将嵌套对象绑定到插件实例
- r - 组中多个项目的推荐系统 (R)
- python - python 正则表达式匹配具有多个空格的字符串