bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: io.c incompatible pointer between public.read_func and ssize_t(*)()


From: Eli Zaretskii
Subject: Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23
Date: Sun, 11 Aug 2024 18:34:28 +0300

> From: arnold@skeeve.com
> Date: Sun, 11 Aug 2024 09:16:33 -0600
> Cc: jeffrey.cliff@gmail.com, bug-gawk@gnu.org
> 
> > If this is the issue, then a trivial wrapper around 'read' is IMO
> > cleaner:
> >
> >   static ssize_t wrap_read (int fd, void *buf, size_t size)
> >   {
> >      return read (fd, buf, size);
> >   }
> 
> If read has different argument or return types on some system,
> that will just generate warnings.

How can 'read' have incompatible types for arguments or return type?
'read' is a system call, so any differences must be compatible.  The
statement

  return read (fd, buf, size);

will transparently promote or cast the return value to ssize_t if
needed, and will likewise promote any type of SIZE argument to size_t.

> > Casts are less clean, and can even be dangerous if the actual
> > signature is really different.
> 
> In the case of read(), I don't think there's anything to worry about.

Then there's nothing to worry about with the wrapper, either.

> My concern is for the more outlying systems like VMS on IBM z/OS.

What are their prototypes for 'read'?  I have no access to those
systems to find out myself.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]