Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site utcsri.UUCP Path: utzoo!utcsri!greg From: greg@utcsri.UUCP (Gregory Smith) Newsgroups: net.lang.c Subject: Re: type cast in initializer Message-ID: <2189@utcsri.UUCP> Date: Mon, 24-Feb-86 16:54:20 EST Article-I.D.: utcsri.2189 Posted: Mon Feb 24 16:54:20 1986 Date-Received: Mon, 24-Feb-86 17:44:36 EST References: <1058@brl-smoke.ARPA> Reply-To: greg@utcsri.UUCP (Gregory Smith) Organization: CSRI, University of Toronto Lines: 17 Summary: >> >The values of '\377' and -1 are one and the same without a type cast. I have lost of track of who originally said that, but it is presented as evidence that '\377' ( or any char constant, e.g. 'x' ) is of type (int), not of type (char). This is not evidence though, since int x; x = 'a'; will convert 'a' to (int) if it was not already, before assigning. This includes sign extending if that is the convention on your system. The same applies to func('x') and case '\300':. Thus the equality between -1 and '\377' does not mean that they are both int's. The only way to tell is to do a sizeof('x'), which is 1 if 'x' is (char) and 2 or 4 or .. if 'x' is int. Having said this, I will add that char constants are in fact of type (int), which can be verified by the above test. ( I speak for 4.2BSD). Greg Smith University of Toronto