Re: Mangled function prototypes (phantom arguments)

Alejandro Colomar <[email protected]> Fri, 29 May 2026 00:11:29 +0200
Newsgroups org.kernel.vger.linux-man
Message-ID <ahi9cQU7htXQNrhl@devuan>
On 2026-05-29T00:10:23+0200, Alejandro Colomar wrote:
> 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.

Oh well, this one won't compile, because of void.  But it would work for
other arrays, such as arrays of char.

> 
> 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>



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

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmoYvZAACgkQ64mZXMKQ
wqmTtA/+LQQQ9P2BkIfFlZ+aIqT/pVq0cXeuzvXshVmAvMK0lKyKtvivpquYzAjx
Zy+935S6J2eYq2l9bFwEQ9R0q6rJ59F1FrlQbW1IPr9oaTqrFX1Do+9zo4ktk1Zl
XlpUBbXCx6Yf/IcvouOW1jkTsf5nYAj3dVLZSfPeTmfA8Zpd7LZd9E3egz1V7tlJ
5jOSsvIZTwNRx+QV18fCJQdvxr1u/jEC2sDuBqLxz5dd+4stpYGNFtQXJ11cR5KX
JpxrSXTEjxlQmHLtrrTkkIIVIOGJZ6IaL/784aj5A9aQK8kQwELgrgl1DieF73bg
WVY2HtD6wACRRbELyl/w+vpNYknMCYpgqnVFnX/C1I71ol8QWwglrZLU8S4kBYw7
e174RGHI5MeJSW36o8/Cxxs6S8l+W75ju99RmBAfAux+udH4RoFUKomsWPO43945
ikGVU28aKEplUx6WL51JjHC8tkvHx/0X1EzXrN116tm1SUbrEMF41FVOCVHgj5mk
NpHLfVdR/WFRH1YINSKZoBGzh3JsiUVS5jJohbqRmFj5kxADmUIVkhCcnqbs8e4B
ZL3knq5rbGRgkdeU6V9jYCnCkZmkwHRPUjLaYKawtRDdp591H8DxODO/1/mru8Oa
s2v0A1hf7tO1dVrm61d4+CvDL2VI68sIEasyZ7gks2RWsKYnkDg=
=Zv9V
-----END PGP SIGNATURE-----