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