🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: muc.lists.netbsd.tech.kern
Article #40

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

#40
From: Greg Troxel
Date: Thu, 03 Dec 2026 23:57
51 lines
3934 bytes
Chris Hanson <cmhanson@eschatologist.net> writes:

>> Would this mean that programs that either
>>  use your API
>>  include a header where this is defined
>> 
>> could only be compiled with a compiler in --std=c23 mode?
>
> This is a good point. Apparently -current (both the userspace and
> kernel) are compiled in --std=c23 mode, but I didn’t check whether
> that was explicitly passed or whether it was the compiler’s
> default. The C committee has been *much* better about backwards
> compatibility with existing code in new standards than, say, C++, so
> compilers can be much more aggressive about enabling newer C standards
> by default.

Compiler authors are aggressive in general :-( I wasn't really worried
so much about building the NetBSD sources.

> Nonetheless, this would affect people trying to use alternative
> compilers with NetBSD’s system headers, so even if I did go forward
> with using a typed enum in this API, I’d still probably need to use
> macros to fall back to pre-C23 declarations (like Apple’s APIs do).

It's not just about other compilers.  In pkgsrc, we have run into quita
a few programs that fail to build with --std=c23 (almost always, an
implicit --std because of an aggressive default, when no --std was
passed).   Such programs are usually from a simpler time when just
writing to C99 and not paying attention to passing --std was a fine
thing to do, and expected to work forever.  It pretty much did until
C23.

We've add FORCE_CC_STD=c99 (or gnu99) to such programs, which has the
wrappers add the --std=c99, so the programs are treated as being written
in the language they are actually written in, not an
incompatible-even-if-mostly-compatible newer language.

I am unclear on what our rules are for headers, in terms of if c99 is
enough.  I have not run into "program when set to c99 mode fails to
build because foo.h was included and that needs c11."

All in all, this feels like too much complexity imposed on everyone to
solve a perhaps-theoretical safety problem.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Technical Details
Message-ID: <rmitsktlxxw.fsf@s1.lexort.com>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail
References: <> <94AA8AC2-1142-4439-8701-1A03DF592A90@eschatologist.net>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.karotte.org!news.muc.de!.POSTED.news.muc.de!not-for-mail
From: Greg Troxel <gdt@lexort.com>
Newsgroups: muc.lists.netbsd.tech.kern
Subject: Re: Do all -current compilers support C23 typed enum syntax?
Date: Thu, 03 Dec 2026 18:57:31 -0500
Organization: Newsgate at muc.de e.V.
Sender: tech-kern-owner@NetBSD.org
Approved: news-admin@muc.de
Distribution: world
Message-ID: <rmitsktlxxw.fsf@s1.lexort.com>
References: <> <94AA8AC2-1142-4439-8701-1A03DF592A90@eschatologist.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: news.muc.de; posting-host="news.muc.de:193.149.48.2";
	logging-data="91847"; mail-complaints-to="news-admin@muc.de"
User-Agent: Gnus/5.13 (Gnus v5.13)
Authentication-Results: mail.netbsd.org (amavisd-new);
	dkim=pass (1024-bit key) header.d=lexort.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lexort.com; s=mail;
	t=1796342251; bh=5LevLnoYCrqUaQesXYcJWMpEnPrMRY5k+aeuDF9c+Hk=;
	h=From:To:Cc:Subject:In-Reply-To:References:Date;
	b=ZuqwmGlDaYlhc2yl83Xyeip2qHnLg6UzdTH6v/5btDKGnpiTUx6EUurMyB3ZQqXJQ
	 y4QDbY6y1JE6aOMHqByCaezrZvlWHKEdU96lhQLgwuZ4Ckqpd8kCgdfsxvdfprCBGB
	 3C0z2pmGqeU4GO6lQvFO+LNxtiy4vcuKh8n6OcSs=
In-Reply-To: <94AA8AC2-1142-4439-8701-1A03DF592A90@eschatologist.net> (Chris
	Hanson's message of "Thu, 3 Dec 2026 14:02:21 -0800")
OpenPGP: id=098ED60E
Precedence: bulk
X-Newsgate-Id: f02c70b8849f+
X-No-Archive: Yes