tech-kern archive

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

Re: Do all -current compilers support C23 typed enum syntax?



> Date: Fri, 4 Dec 2026 00:24:53 -0500
> From: Thor Lancelot Simon <tls%panix.com@localhost>
> 
> On Thu, Dec 03, 2026 at 08:31:18PM -0800, Chris Hanson wrote:
> > 
> > In general, this is not a fruitful line of discussion: Compilers
> > do exist to serve their users, but those users have many different
> > and competing needs, and optimization for both speed and size are
> > among them. And the language specification is ultimately what
> > defines "broken" when it comes to how to best meet those needs.
> 
> I have been avoiding so far in this conversation noting that really,
> this all stems from Apple buying itself a 50 gallon drum of trouble
> by just begging for UB by using "enum" in ABI elements, but, this
> seems like the time to say it.
> 
> You have to understand the limitations of the language you're
> working in -- or, if you have a polyglot ecosystem, the languages.
> Using enum in a binary interface to other people's code bespeaks
> profound misunderstanding of the limitations of C and papering over
> it afterwards is bound to be fraught.

I believe Chris already addressed this, so perhaps it's not necessary
to ascribe a profound misunderstanding of the limitations:

https://mail-index.netbsd.org/tech-kern/2026/12/04/msg031347.html

Whether we want to adopt the same approach is a different question,
but evidently Chris and the engineers at Apple who adopted that
approach do understand the limitations of C enums.

For NetBSD's C header files, we are not going to unconditionally use
C23 typed enums -- that's obviously a nonstarter.  But I'm open to
hearing a proposal describing:

(a) macros that _conditionally_ use C23 typed enums and other compiler
    extensions,

(b) two or three specific use-cases for them, and

(c) specific benefits in terms of reliable compiler diagnostics and
    ABI stability.


Home | Main Index | Thread Index | Old Index