how has C bitten you -- unsigned/disnged chars.

Dave Brower daveb at rtech.UUCP
Fri Aug 9 17:31:49 AEST 1985


> In article <5400010 at prism.UUCP> matt at prism.UUCP writes:
> For most applications, it doesn't matter whether a char is signed or
> not, and so it is appropriate for the compiler to select that which
> can be implemented most efficiently. When it does matter, the programmer
> should take care (by explicitly declaring it as signed or unsigned).

When planning to support 8 bit characters for an international character
support, it is annoying that "strings in quotes" are the same thing as
the default (often signed) character type, when you really want them
to be unsigned.  This lint illustrates the situation.

1	iputs( s )
2	unsigned char * s;
3	{
4		while ( *s )
5			iputc( *s++ )
6	}
7
8	foo()
9	{
10		iputs( "hello dere\n" );
11	}

foo.c:
iputs, arg. 1 used inconsistently	foo.c(3)  ::  foo.c(10)

Now don't get me wrong, you *really should* say:

		iputs( (unsigned char *) "hello dere\n" );

and in a real international version you're more likely to have:

		extern unsigned char * msgs[];
		iputs( msgs[47] );

I'm just pointing it out as one of those annoyances one learns to tolerate.

BTW, I'm in favor of (void) printf() etc, if only DEC-C for VMS
supported the damn thing.  Now you need to be write it as VOID printf()
with VOID defined to be an appropriate cast or non-entity.  Ughly.

*sarcasm on*
Won't it be great when ANSI-C is implemented on EVERY machine you want
to use?
*sarcasm off*
-- 
{amdahl|dual|sun|zehntel}\		|"If his brains ran down, how could
{ucbvax|decvax}!mtxinu---->!rtech!daveb |he talk?"
ihnp4!{phoenix|amdahl}___/		|"Happens to people all the time...."



More information about the Comp.lang.c mailing list