[alt.sys.sun] Sun C - is it missing a type specifier?

garvey@johnny5.uucp (Joe Garvey) (02/11/91)

I was just porting some code from another system (HP), and I ran into
a funny problem. The Sun C compiler complained about my using the 
"signed" type specifier with a char.

The new K&R says (pg 211):

	At most one of signed or unsigned may be specified together with int
	or any of its short or long varieties or with char. Either may appear
	alone, in which case int is understood. The signed specifier is
	useful for forcing char objects to carry a sign; it is permissible
	but redundant with other types.

My solution (since Sun C says char's are signed unless explicitly specified
as unsigned) was to create a "typedef char S_CHAR;". This would then allow
me to substitute "typedef signed char S_CHAR;" in the event I end up
going to a machine that has unsigned chars as a default.

I'm still kinda surprised that the Sun C compiler (unbundled one) doesn't
allow "signed char". Is there a reason for this? Is it an oversite? Did
I screw up?


-- 

Joe Garvey                       uucp: sumax!ole!johnny5!garvey
J5 Research                      registration has been sent in, though we're
Bothell, Wa.                     not in the maps yet.

henry@zoo.toronto.edu (Henry Spencer) (02/12/91)

In article <1991Feb11.050706.18745@johnny5.uucp> garvey@johnny5.uucp (Joe Garvey) writes:
>I'm still kinda surprised that the Sun C compiler (unbundled one) doesn't
>allow "signed char". Is there a reason for this? Is it an oversite? Did
>I screw up?

You are being optimistic if you expect K&R2 to apply to every C compiler
in the world.  Many old compilers -- including Sun's unbundled one -- are
nowhere near conformance to ANSI C.
-- 
"Read the OSI protocol specifications?  | Henry Spencer @ U of Toronto Zoology
I can't even *lift* them!"              |  henry@zoo.toronto.edu  utzoo!henry