Menu

#45 #include <termios.h> missing in Common/x3270if.c

v1.0 (example)
closed-fixed
None
5
2025-07-01
2025-06-03
No

When building 4.4ga6 for pkgsrc on NetBSD 10.1, I got this error:

../../../Common/x3270if.c: In function 'echo_mode':
../../../Common/x3270if.c:472:20: error: storage size of 't' isn't known
  472 |     struct termios t;  
      |                    ^
../../../Common/x3270if.c:474:5: warning: implicit declaration of function 'tcge
tattr'; did you mean 'tgetstr'? [-Wimplicit-function-declaration]
  474 |     tcgetattr(0, &t);  
      |     ^~~~~~~~~
      |     tgetstr
../../../Common/x3270if.c:476:22: error: 'ECHO' undeclared (first use in this fu
nction)
  476 |         t.c_lflag |= ECHO;
      |                      ^~~~
../../../Common/x3270if.c:476:22: note: each undeclared identifier is reported o
nly once for each function it appears in
../../../Common/x3270if.c:480:5: warning: implicit declaration of function 'tcse
tattr' [-Wimplicit-function-declaration]
  480 |     tcsetattr(0, TCSANOW, &t);
      |     ^~~~~~~~~
../../../Common/x3270if.c:480:18: error: 'TCSANOW' undeclared (first use in this function)
  480 |     tcsetattr(0, TCSANOW, &t);
      |                  ^~~~~~~

(and a few similar ones more)
This comes from this code:

/* Set or clear echo mode. */
static void
echo_mode(bool echo)
{
#if defined(_CURSES) /*[*/
    struct termios t;

    tcgetattr(0, &t);
    if (echo) {
        t.c_lflag |= ECHO;
    } else {
        t.c_lflag &= ~ECHO;
    }
    tcsetattr(0, TCSANOW, &t);

This needs an #include <termios.h>.
I hacked one in, but configure should really check for this:

--- Common/x3270if.c.orig       2025-06-03 16:26:13.982966781 +0000
+++ Common/x3270if.c
@@ -74,6 +74,9 @@
 #  include <curses.h>
 #  define _CURSES 1
 # endif /*]*/
+#if defined _CURSES
+#include <termios.h>
+#endif
 # if defined(HAVE_NCURSESW_TERM_H) /*[*/
 #  include <ncursesw/term.h>
 # elif defined(HAVE_NCURSES_TERM_H) /*][*/

NetBSD's manual page for tcgetattr() etc specifies that the include is necessary.
Maybe there is some curses function that could be used, which wraps the functionality that is used here.

Discussion

  • Paul Mattes

    Paul Mattes - 2025-07-01
    • assigned_to: Paul Mattes
     
  • Paul Mattes

    Paul Mattes - 2025-07-01

    Fix is committed. It will be in the next release(s).

     
  • Paul Mattes

    Paul Mattes - 2025-07-01
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB