Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Something C might need Date: Wed, 27 Sep 2017 09:01:03 -0700 Organization: None to speak of Lines: 48 Message-ID: References: <1cc86992-d71e-42b9-818f-f883b78e79ce@googlegroups.com> <7ac3b44a-b838-4462-88c8-adcd77d61ce1@googlegroups.com> <87wp4p4sej.fsf@bsb.me.uk> <87k20p3p8s.fsf@bsb.me.uk> <2GDxB.1282792$zs1.548390@fx15.am4> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="c4326c8a8501fb80bdc9708804691d40"; logging-data="25536"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/YVyRl0XQtOlPPwPgkjqq6" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:9xFDCEEJMS+GIBvAGBZllVDCjXw= sha1:funJiVXzl8Vh7W3WT8GvvIjq4oU= Xref: csiph.com comp.lang.c:120373 David Brown writes: [...] > (Personally, I would prefer standard integer types to be compatible with > each other if they are of the same size. Personally, I think that would be a bad idea. You mention _Generic downthread. Making types of the same size compatible would pretty much kill any use of _Generic for integer types. A generic selection that uses "int" and "long" would be legal in some implementations, illegal in others. And there wouldn't be much benefit. You could write non-portable code that assumes, for example, that int and long are compatible -- but such code could and probably should be modified to use one type or the other. > In fact, I'd rather have the > types as being the fundamental ones in C, with "int" being a > typedef for "int_fast16_t", "long" being a typedef for "int_fast32_t", > and so on. But C I don't waste many tears about what C could have been, > as long as it works fine for what I need.) The fact that each of the intN_t types is compatible with *some* built-in integer type, but you can't portably assume which one, is IMHO a bit of a problem. This: int a; int32_t *b; *b = a; is valid in some implementations, a constraint violation in others. I would have liked to have a method, similar to typedef, that defines a new and incompatible type with the same characteristics as an existing type. Then int, long, int32_t, and int64_t could all be distinct and incompatible types. (A current implementation could do this by making the [u]intN_t types typedefs for extended integer types.) But again, that would mess up _Generic for integer types. [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"