【发布时间】:2015-04-01 03:33:27
【问题描述】:
在我目前正在处理的程序中,我多次遇到这个问题,其中 gcc 无法识别我从库中导入的函数或文件类型,即使 include 指令明显位于顶部与所有其他人一起编程。为了解决这个问题,我一直在寻找类似的库并使用其中的函数,但是对于我现在正在尝试做的事情,我发现的库都没有工作。这是我的指令列表:
#include "oscar.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <libgen.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <time.h>
#include <utime.h>
#include <malloc.h>
我目前正在尝试更改文件中的访问和修改时间。我尝试过使用 utime()、utimes()、futimens() 和其他几个变体,它们都遇到了同样的问题。 GCC 不能识别许多函数或文件类型。例如,我正在尝试使用 futimens():
futimens(m_file_desc, times);
但是 gcc 给出以下错误
warning: implicit declaration of function ‘futimens’
【问题讨论】:
-
能否提供一段简单的可编译代码,我们可以试试?
-
你的平台和 glibc 版本是什么?来自手册页:
Support for futimens() first appeared in glibc 2.6. -
我正在使用教授为我的班级设置的 unix 虚拟机。我认为 futimens 会起作用,因为这实际上是他推荐使用的功能
-
在您的 bash shell 中输入:locate sys/stat.h 并告诉我们它是否会为您提供结果。然后输入 gcc -print-search-dirs 并发布结果。
-
它给出了很多结果,这是第二件事: