Re: Mangled function prototypes (phantom arguments)

Alejandro Colomar <[email protected]> Fri, 29 May 2026 00:10:19 +0200
Newsgroups org.kernel.vger.linux-man
Message-ID <ahi7dckZtycvn_Ql@devuan>
Hi Mark,

On 2026-05-28T14:43:21-0700, Mark Harris wrote:
> > > My view was always that they were the simplest expression of the
> > > interface that the widest possible audience could understand, and
> > > that seems to align with Michael's view.
> >
> > That doesn't provide much value, IMHO.  My opinion of the SYNOPSIS is
> > that it's a quick reminder of how a function should be used.
> 
> I suggest a compromise.  Keep the array sizes, which are the part that
> you claim adds value, and drop the forward declarations, which are the
> part that confuses people.  So for example:
> 
> ssize_t read(int fd, void buf[count], size_t count);
> 
> Yes, count is used before its definition, but the goal is not to write
> a valid function declaration; the existing one being invalid is
> evidence of that.  It is difficult to imagine that anyone would have
> trouble finding the definition of count without a forward declaration,
> unless they are a compiler in which case they would also be tripped up
> by the array-of-void.

I considered doing that some time ago.  I am worried about something: it
might "work" if you're unlucky.

Let's say a relatively new programmer sees this and thinks it's valid C.
And let's say it tries it in their own code, which may have a variable
in scope (most likely, a global one) named 'count'.

	extern int count;

	ssize_t read(int fd, void buf[count], size_t count);

That's going to compile, but it's not what you'd expect.

That's why I originally used [.count] notation.  That one if free from
this problem.  However, GCC maintainers convinced me of using some
syntax that is valid C (at least in the GNU dialect of it, which is the
majoritary one anyway).


Have a lovely night!
Alex

-- 
<https://www.alejandro-colomar.es>
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmoYvUQACgkQ64mZXMKQ
wqndTRAAl2Pz00ZxKVAfRFn+944+wT5JPyeMhW9/T9+yvVvEkkOEgQXAK6WVYFE6
+u4rx/Gbrzdj6rmTJ/zVaXxJAe0tS9NHw3WNZu5ypGU7jP41jswmyuwEolXEZk+y
k77GkzDGlSJ4CSPb618J/T7Pomo0neWTiI+6VHWcoqd97zKhMo8wkJRQwIrqqRCS
EN9rwk4HN8w679ZReDS7B4hVjULVZDLg5xwYen/Ytk79PtwOIH1fIkjuu74JyVct
KZrGgZuWvbmeXJQWkjDCWEGSOUDnp0MfQdSqhMbGlW+4TKmHGjXg78oDoyzJpKV6
RzmJAuGroY9mcfnvpnMKEOAYeVcRYx6hT06JdAJumd/uR1RIdxw+3FF1Ad1PhIWI
u4QnHOWvH6iuE6auhwBmjkWA8J7yqmKTa35w41Tv7505yP5qG1pUbBUMVYRCuF8i
50sqY2xTZ4kZMHVBBSu62oZv3ePCk3pLS3D4OA3EWspnSXnyFVdq22OkXRel23vJ
u6k1DQesJbmvnK48R1IZ/baB8Q36QU8N0w8DPN+7pBXskkGlA75DiSI1lhE7yHOT
9hbsAgP6sC4be06Dg0DiCWjsEARXGWablwWrO20yj9kyw5FoxdvBpJ85hMKEZOn/
dD7IRX0sWPs7FC78a8+ra1oMrfYroVpVJM/XhD4fw52WxKQy148=
=7wgd
-----END PGP SIGNATURE-----