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: unsigned int Date: Tue, 02 Aug 2016 08:00:14 -0700 Organization: None to speak of Lines: 39 Message-ID: References: <87h9b4uy39.fsf@bsb.me.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="4654"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DoBA45O39+/3ajhSAxANu" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:4fw2CxK8ecIU/jAMKTqj9KQXjFM= sha1:FBY2X5tTuzEd8IovyLyMWnMvZsA= Xref: csiph.com comp.lang.c:91566 Les Cargill writes: > David Brown wrote: >> On 02/08/16 01:20, Les Cargill wrote: [...] >>> While it's implementation dependent, it's unusual for "unsigned" to be >>> the actual default - unless overridden. >> >> I think that is a wild generalisation, without basis in fact - unless >> you can point us to a list of compilers, targets, and the signedness of >> their chars. > > Hence "unless overridden". The defacto, default standards for the 'C' > language are "char is a smaller int" and "ints are signed by default." char is not "a smaller int". char and int are both integer types. And yes, char is almost always smaller than int. Yes, int is signed by default. In fact, int is signed; it's not just a default, it's a firm language rule. Is that what you meant? I think you meant to say, or imply, that plain char is signed by default. That statement is neither true nor useful. And upthread, you wrote the opposite (which is also misleading): Default char in 'C' is always unsigned unless you use compiler options to make it otherwise, or unless the compiler defaults it for you. There is no default signedness for type char. It is either signed or unsigned, depending on the implementation. It's probably true that most modern hosted impleentations make plain char signed, but that does not constitute a "default". Code that's intended to be even minimally portable must not depend on the signedness of plain char. -- 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"