如何在terios.h中定义CRTSCTS?

问题描述 投票:0回答:1

我的机器有 CRTSCTS #定义在一个 #ifdef __USE_MISC 这使得我编译的C程序无法使用它。

usrincludex86_64-linux-gnubitstermios.h。

...       
#define  B4000000 0010017
#define __MAX_BAUD B4000000
#ifdef __USE_MISC
# define CIBAUD   002003600000      /* input baud rate (not used) */
# define CMSPAR   010000000000      /* mark or space (stick) parity */
# define CRTSCTS  020000000000      /* flow control */
#endif

/* c_lflag bits */
#define ISIG    0000001
#define ICANON  0000002
...

我怎样才能在不黑掉CRTSCTS的值的情况下访问它呢?020000000000 纳入我的程序?

我已经 #include <termios.h> 和许多其他头文件。

我也在使用。

#define __USE_POSIX199309
#define _POSIX_C_SOURCE 199309L
#include <time.h>    /* nanosleep needs lines above */
c ubuntu-18.04 termios flow-control
1个回答
1
投票

这个 __USE_MISC 宏是一个内部定义,虽然我想你可以自己定义,但最好是找到合适的功能测试宏来实现它。

在我的CentOS 7系统上。/usr/include/features.h 有一系列这类宏,看来 __USE_MISC 通过以下方式启用 _BSD_SOURCE_SVID_SOURCE;不清楚哪一个与你需要的其他东西兼容。

... // features.h
#if defined _BSD_SOURCE || defined _SVID_SOURCE
# define __USE_MISC     1
#endif

试试 #define _BSD_SOURCE 在你的程序的顶部--在所有的包含之前--看看它是如何进行的。

参考文献 http:/man7.orglinuxman-pagesman7feature_test_macros.7.html)。

© www.soinside.com 2019 - 2024. All rights reserved.