Character types in ANSI C

cg at myrias.UUCP cg at myrias.UUCP
Sat Feb 14 10:44:07 AEST 1987


If this is a duplicate, I apologize, our poster was broken.

What exactly are the compatibility rules for character types in ANSI C?
I.e. which of the following are legal:

    char *p1;
    unsigned char *p2;
    signed char *p3;

    p1 = p2;	    /* case 1 */
    p1 = p3;	    /* case 2 */
    p2 = p3;	    /* case 3 */

I see three choices:

a) they are all legal

b) they are all illegal

c) case 3) and one of cases 1) and 2) are illegal, depending on whether
    the implementation treats 'char' as signed or unsigned.

I've currently implemented choice c), but am concerned that this will
result in programs that compile on some implementations and not others (and
vice versa). Several of us have argued about it here, but we can't find
anything solid in the draft.

Any definitive answers would be appreciated. Thanks in advance.

		Chris Gray {ubc-vision,sask,ihnp4}!alberta!myrias!cg



More information about the Comp.lang.c mailing list