gpt4 book ai didi

c - O_RDWR 终端未声明

转载 作者:太空宇宙 更新时间:2023-11-04 05:53:11 24 4
gpt4 key购买 nike

我使用的是更新和升级的 ubuntu 14.0.4LTS。

我写了一个串口通信的代码。

 #include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <errno.h>
#include <sys/stat.h>
#include <termios.h>

以上文件已包含在代码中。

当我编译代码时,它返回错误“O_RDWR undeclared”如果我包含 fcntl.h,则编译器返回错误“参数 1 的类型不兼容”,这意味着打开函数需要 const char* 类型的参数。

struct termios TtyN;
open( TtyN, O_RDWR );

类型转换不合适。什么是正确的解决方案?

最佳答案

man 2 open将显示 open() 所需的头文件。即,

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

接下来我建议查看 man 3 termios .

关于c - O_RDWR 终端未声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34304290/

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