gpt4 book ai didi

c - 包含不导入的指令

转载 作者:行者123 更新时间:2023-11-30 17:21:33 25 4
gpt4 key购买 nike

我在当前正在处理的程序中多次遇到此问题,其中 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’

最佳答案

您可能需要指定 feature test macros .

来自手册页:

futimens():
Since glibc 2.10:
_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
Before glibc 2.10:
_GNU_SOURCE

因此,根据您的 glibc 版本,您需要定义 _GNU_SOURCE_XOPEN_SOURCE_POSIX_C_SOURCE具有适当的值。

关于c - 包含不导入的指令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28273490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com