[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: |
Sat, 10 Aug 2024 22:01:52 +0300 |
> From: Jeffrey Cliff <jeffrey.cliff@gmail.com>
> Date: Sat, 10 Aug 2024 12:42:15 -0600
> Cc: bug-gawk@gnu.org
>
> Of course.
>
> * this also occurs on main / c190576f
>
> * read in this question is just read(2)
> ssize_t read(int fd, void buf[.count], size_t count);
>
> * interestingly, it seems like gcc is smart enough to figure out what
> the type read_func needs without explicit casting(?) -- ie just
> getting rid of explicit cast allows not only compile, but all tests to
> work(?) and gawk seems to run fine
>
> so one possible fix is just something like
>
> # git diff c190576fd345d9c098901061f0fd4164a7bfc87f io.c
> diff --git a/io.c b/io.c
> index 3943c5a9..54abf110 100644
> --- a/io.c
> +++ b/io.c
> @@ -3388,7 +3388,12 @@ iop_alloc(int fd, const char *name, int errno_val)
>
> iop->public.fd = fd;
> iop->public.name = name;
> - iop->public.read_func = ( ssize_t(*)() ) read;
> + #if __STDC_VERSION__ >= 202311L
> + iop->public.read_func = read;
> + #else
> + iop->public.read_func = ( (ssize_t(*)() ) read;
> + #endif
> +
> iop->valid = false;
> iop->errcode = errno_val;
I don't understand why we need this jumping-through-hoops. If you (or
Aharon or someone else) do, please explain the need.
If the problem is that some system headers declare 'read' to return an
'int', not 'ssize_t', then the way to deal with that is to provide a
trivial wrapper around 'read' that returns 'ssize_t'.
- io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, Jeffrey Cliff, 2024/08/10
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, arnold, 2024/08/10
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, Jeffrey Cliff, 2024/08/10
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23,
Eli Zaretskii <=
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, arnold, 2024/08/10
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, Jeffrey Cliff, 2024/08/10
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, arnold, 2024/08/10
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, Eli Zaretskii, 2024/08/11
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, Collin Funk, 2024/08/11
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, arnold, 2024/08/11
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, Eli Zaretskii, 2024/08/11
- Re: io.c incompatible pointer between public.read_func and ssize_t(*)() with c23, arnold, 2024/08/11