Deutsch English Français Italiano |
<v4vuc0$27pi6$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!feeds.phibee-telecom.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Lawrence D'Oliveiro <ldo@nz.invalid> Newsgroups: comp.lang.c Subject: Re: C23 enums Date: Thu, 20 Jun 2024 00:50:09 -0000 (UTC) Organization: A noiseless patient Spider Lines: 28 Message-ID: <v4vuc0$27pi6$1@dont-email.me> References: <v4jlfs$3d46g$1@dont-email.me> <v4rbaa$17q05$1@dont-email.me> <v4rpsp$1alv6$1@dont-email.me> <v4u12o$1rq9m$1@dont-email.me> <v4ujg0$1vgo2$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 20 Jun 2024 02:50:09 +0200 (CEST) Injection-Info: dont-email.me; posting-host="8d4a96747c03a32f35aacdb634ed6221"; logging-data="2352710"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ZPjDD63lpvDi0RKSMqvef" User-Agent: Pan/0.158 (Avdiivka; ) Cancel-Lock: sha1:yBKpjjs/fRf+AMcfz8O82ZY4Lvs= Bytes: 1984 On Wed, 19 Jun 2024 09:38:24 -0300, Thiago Adams wrote: > On 19/06/2024 04:24, Lawrence D'Oliveiro wrote: > >> On Tue, 18 Jun 2024 08:09:13 -0300, Thiago Adams wrote: >> >>> This creates a kind of encapsulation. >> >> Why not just use “int” or “unsigned int”? Why does the caller even need to >> know it’s an enum? > > The advantage will be the type check at the implementation file (some > compiler have extra type check for enuns) ... Obviously this is not a language requirement, so I’m not sure of the point. E.g. GCC compiles this rather flagrant example without complaint: enum colours {red, green, blue}; enum colours colour = 9; I even tried “-Wall -Wpedantic”, to no effect. > ... and clarity about the possible values accepted. As a documentation aid? Again, that’s implementation-specific, nothing to do with the caller-visible interface.