c - O_RDWR 终端未声明

标签 c ubuntu terminal ubuntu-14.04

我使用的是更新和升级的 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/

相关文章:

无法将 int 打印到文件

ubuntu - 如何在 Win 10 中使用 WSL Ubuntu Bash 开发 Go App

ubuntu - 无法在 Ubuntu 22.04 中拖放

c - 带电围栏库的gcc不生效

macos - mac上的usr/local/src不存在吗?

c++ - 我不断收到 clang : error: no input files in C++

c - 将一个 .so 与另一个 .so 链接时 undefined symbol

c - C中常量的奇怪声明

c++ - 关于MASM汇编器 "Link Map"输出和 "Assume"指令的问题

linux从现有的公钥创建新的私钥