Apple LLVM 版本 10.0.0 (clang-1000.10.44.4)
目标:x86_64-apple-darwin18.0.0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#define _GNU_SOURCE
#define __USE_GNU 1
#include <fcntl.h>
int main()
{
int fd = open("./test.txt", O_WRONLY|O_DIRECT);
close(fd);
return 0;
}
我使用 clang -o out test.c
得到以下结果:
test.c:14:39: error: use of undeclared identifier 'O_DIRECT'
int fd = open("./test.txt", O_WRONLY|O_DIRECT);
我该如何解决这个问题?
谢谢。
最佳答案
使用此代码段无法说明您正在尝试做什么,但通常不要在可移植的应用程序中使用非标准内容。
完成任务的可移植方式可能 fsync
。
关于c - 使用未声明的标识符 'O_DIRECT',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55281353/