On Wed, 2026-12-02 23:36:21 -0800, Chris Hanson <[email protected]> wrote: > I’m designing a subsystem (including system calls) and I’d like to > use “typed enums” in the API rather than #define or anonymous enums > and int parameters. > > For example: > > typedef enum : int { > subsys_thing_a = 0, > subways_thing_b, > } subsys_thing_t; > > int subsys_call(subsys_thing_t thing); > > Many years ago at Apple we brought these from C++ to Objective-C and > C because they can dramatically improve debugging ergonomics, and > they’re part of C23, but can we actually require C23 for -current? > > Experimentally, I’ve verified that they work without complaint or > problem on virt68k (my preferred machine to use for experiments, for > debugging ease) but I’d wonder about things like VAX.
There are two primary compilers used in NetBSD, see
src/external/gpl3/gcc{,.old}. Supporting specific versions of language
standards is primarily based on the compiler's version (or age), less
so on the backend. VAX is special among all platforms that NetBSD
support in that it predated IEEE 754 floating point support, so a
program that expects '754 fpu support will potentially fail in some
way. But those typedef'ed enums aren't FPU, so...
vax-template# gcc --version
gcc (nb4 20260926) 14.4.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
vax-template# uname -a
NetBSD vax-template.classiccmp 11.99.9 NetBSD 11.99.9 (GENERIC) #0: Wed Oct 28
09:49:53 UTC 2026
[email protected]:/usr/src/sys/arch/vax/compile/GENERIC vax
vax-template# cat test.c
#include <stdio.h>
typedef enum: int {
subsys_thing_a = 0,
subways_thing_b,
} subsys_thing_t;
int
subsys_call (subsys_thing_t thing)
{
printf ("Num: %i\n", (int) thing);
return 0;
}
int
main (int argc, char *argv[])
{
return subsys_call (subways_thing_b);
}
vax-template# gcc -Wall -Werror -pedantic -std=c23 test.c
vax-template# ./a.out
Num: 1
vax-template#
Right now, _all_ NetBSD ports use the same GCC 14 (this is "gcc", not
"gcc.old"). The last to switch were m68k and alpha, which used gcc.old
until Oct 17, 2026, see src/share/mk/bsd.own.mk .
MfG, JBG
--
signature.asc
Description: PGP signature
