tech-userlevel archive

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

Re: major/minor(3) macros conflict with regular code



At Fri, 7 Feb 2025 09:59:15 +0100, Anthony Mallet <anthony.mallet%laas.fr@localhost> wrote:
Subject: Re: major/minor(3) macros conflict with regular code
>
> On Thursday  6 Feb 2025, at 18:01, Greg A. Woods wrote:
> > At Thu, 6 Feb 2025 23:48:48 +0100, Anthony Mallet
> > <anthony.mallet%laas.fr@localhost> wrote: Subject: major/minor(3) macros
> > conflict with regular code
> > >
> > > Do major(3) and minor(3) really need to be macros?
> >
> > What do you mean "need to be"?
>
> I meant: they could be static inline functions without breaking
> anything, I guess?

That was the point of my mentioning their history -- it's unlikely
anyone is willing to risk change such long-standing system C code just
to work around some non-C problems with one or a very few applications.

> It's actually sys/featuretest.h that defines _NETBSD_SOURCE under the
> hood, not me :)

But as you noticed that's only by default.  If the application chooses a
different compatability option then that default is avoided and it's up
to the application to then choose to define _NETBSD_SOURCE, but only if
and when it needs to.

When _NETBSD_SOURCE is defined, the "NetBSD Standard" with its (implied)
namespace is in effect and that namespace (effectively) defines "major"
and "minor" as reserved identifiers.  Probably this should all be
documented somewhere more clearly, but as far as I know this tedious and
probably not very rewarding task hasn't been taken on by anyone.
Perhaps it could be mechanised somewhat though given that it is all
encoded in the system headers.

> > Or fix that code to use more descriptive and thus unique names for
> > those methods!  :-)
>
> Well, the code is just:
> message Version
> {
>   int32 major = 1;
>   int32 minor = 2;
> }

So, I'm definitely not a C++ programmer, but wouldn't this be so easy as
changing the member names?

	message Version
	{
		int32 my_protocol_major = 1;
		int32 my_protocol_minor = 2;
	}

--
					Greg A. Woods <gwoods%acm.org@localhost>

Kelowna, BC     +1 250 762-7675           RoboHack <woods%robohack.ca@localhost>
Planix, Inc. <woods%planix.com@localhost>     Avoncote Farms <woods%avoncote.ca@localhost>

Attachment: pgp76p8GZmKJk.pgp
Description: OpenPGP Digital Signature



Home | Main Index | Thread Index | Old Index