sys/termios.h defines struct winsize after it is referenced in function signatures

Zachary Santer zsanter@gmail.com
Fri Jul 18 04:02:05 GMT 2025


Was "MacOS Homebrew bash '5.3.0(1)-release' breaks 'wait' (?)" on
bug-bash@gnu.org.
On Thu, Jul 17, 2025 at 12:05 PM Chet Ramey <chet.ramey@case.edu> wrote:
>> On 7/17/25 8:51 AM, Sam James wrote:
> > Zachary Santer <zsanter@gmail.com> writes:
> >
> >> I've applied your patch, but gcc 15.1.0 has decided that a 'struct
> >> winsize *' not being a 'struct winsize *' is an error now.
> >>
> >> Configuration Information [Automatically generated, do not change]:
> >> Machine: x86_64
> >> OS: cygwin
> >> Compiler: gcc
> >> Compilation CFLAGS: -Wno-error=incompatible-pointer-types
> >> uname output: MSYS_NT-10.0-26100 Zack2021HPPavilion
> >> 3.6.3-ab81aae6.x86_64 2025年07月01日 18:20 UTC x86_64 Msys
> >> Machine Type: x86_64-pc-cygwin
> >>
> >> Bash Version: 5.3
> >> Patch Level: 0
> >> Release Status: maint
> >>
> >> Would be nice if bashbug were generated even if bash itself failed to build.
> >>
> >> From before I changed CFLAGS, obviously:
> >>
> >> winsize.c: In function 'get_new_window_size':
> >> winsize.c:98:39: error: passing argument 2 of 'tcgetwinsize' from
> >> incompatible pointer type [-Wincompatible-pointer-types]
> >> 98 | if (tty >= 0 && (tcgetwinsize (tty, &win) == 0) &&
> >> win.ws_row > 0 && win.ws_col > 0)
> >> | ^~~~
> >> | |
> >> | struct winsize *
> >> In file included from /usr/include/sys/ioctl.h:15,
> >> from winsize.c:31:
> >> /usr/include/sys/termios.h:304:42: note: expected 'struct winsize *'
> >> but argument is of type 'struct winsize *'
> >> 304 | int tcgetwinsize(int fd, struct winsize *winsz);
> >
> > This is probably a visibility of the type issue:
> > https://gcc.gnu.org/PR117866.
>> OK. Where is `struct winsize' declared if not in termios.h or ioctl.h
> (or the nest of includes for old systems)?
>> https://pubs.opengroup.org/onlinepubs/9799919799/functions/tcgetwinsize.html#tag_17_609
>> says that if libc has tcgetwinsize(), you only need <termios.h> to get
> its declaration.

I've attached the /usr/include/sys/termios.h file included in my MSYS2
installation. As you can see, struct winsize is defined after it is
referenced in the function declarations of tcgetwinsize() and
tcsetwinsize() in that file.
I moved the definition of struct winsize to above the function
declarations, and bash built without issue.
This is a Cygwin bug, so I've included their email list on the To:
line. The MSYS2 people don't use an email list anymore, so if I need
to get in touch with them, I'll have to file an issue on their Github.
--- orig/termios.h 2025年07月17日 23:26:00.518408600 -0400
+++ fixed/termios.h 2025年07月17日 23:28:00.517939200 -0400
@@ -284,6 +284,13 @@
 #define termio termios
+/* Extra stuff to make porting stuff easier. */
+struct winsize
+{
+ unsigned short ws_row, ws_col;
+ unsigned short ws_xpixel, ws_ypixel;
+};
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -313,13 +320,6 @@
 #define cfgetospeed(tp) ((tp)->c_ospeed)
 #endif
-/* Extra stuff to make porting stuff easier. */
-struct winsize
-{
- unsigned short ws_row, ws_col;
- unsigned short ws_xpixel, ws_ypixel;
-};
-
 #define TIOCGWINSZ (('T' << 8) | 1)
 #define TIOCSWINSZ (('T' << 8) | 2)
 #define TIOCLINUX (('T' << 8) | 3)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: termios.h
Type: text/x-c-code
Size: 7215 bytes
Desc: not available
URL: <https://cygwin.com/pipermail/cygwin/attachments/20250718/99b33db2/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 47605 bytes
Desc: not available
URL: <https://cygwin.com/pipermail/cygwin/attachments/20250718/99b33db2/attachment-0001.obj>


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /