happy <> writes:
> On Jan 14, 10:22Â*pm, Keith Thompson <ks...@mib.org> wrote:
>> happy <hppymit...@yahoo.com> writes:
>> > As signed char and plain char can be different if plain char is
>> > unsigned in a particular implementaion,
>> > Can signed int and plain int be different or are they guaranteed to be
>> > same?
>>
>> Plain char and signed char are always distinct types. Â*They may or
>> may not have the same representation.
>>
> Even if plain char is signed, then also are plain and signed char
> distinct ?
Yes.
> I mean can they have different representations?
No.
If plain char is signed, then plain char and signed char are two
disinct types with exactly the same range and representation.
Some examples:
char c = 'c';
signed char s = 's';
/* The actual values are not important */
c = s; /* ok, involves an implicit type conversion */
s = c; /* ok, as above */
/* Note that the implicit type conversions above don't do
any actual work.
*/
char *pc = &c;
signed char *ps = &s;
pc = ps; /* constraint violation, requires a diagnostic */
ps = pc; /* constraint violation, requires a diagnostic */
Since C permits implicit conversions between any two arithmetic
types, the fact that two such types are distinct *usually* isn't very
important. But pointers to two such distinct types are themselves
distinct pointer types, and there are no implicit conversions for
distinct pointer types (other than void* and some special cases
for null pointer constants)
--
Keith Thompson (The_Other_Keith)
kst- <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"