[net.lang.c] how has C bitten you -- unsigned/disnged chars.

daveb@rtech.UUCP (Dave Brower) (08/09/85)

> In article <5400010@prism.UUCP> matt@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...."

dhb@rayssd.UUCP (David H. Brierley) (08/15/85)

> 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.

If you get the newest version of the VAX11-C compiler from DEC, you
will find that it DOES support (void).  The version that we have is
identified as "V2.0-003".  I was quite pleased when they finally
added this because I frequently port software between UNIX and VMS
and was tired of having to go through convolutions to get around this.
I never used VOID however, I simply would use typedef and change the
"void" into and "int".
-- 
	Dave Brierley
	Raytheon Co.; Portsmouth RI; (401)-847-8000 x4073
	...!decvax!brunix!rayssd!dhb
	...!allegra!rayssd!dhb
	...!linus!rayssd!dhb

eric@grkermi.UUCP (Eric N. Starkman) (08/16/85)

In various articles, people write:
>> ...if only DEC-C for VMS supported ...
>
>...the newest version of the VAX11-C compiler from DEC...
>...I frequently port software between UNIX and VMS...

int foo(procedure)
	int (*procedure)();
{
	...
	procedure();
	...
}

Though this isn't the proper way to do it, it compiles and runs without
problem under 4.2 and VMS/C 1.something  .

VMS 2.0 requires the procedure(); call to be (*procedure)();