Character types in ANSI C

john at viper.UUCP john at viper.UUCP
Sun Feb 22 06:36:12 AEST 1987


In article <816 at cullvax.UUCP> drw at cullvax.UUCP (Dale Worley) writes:
 >cg at myrias.UUCP (Chris Gray) writes:
 >> 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 */
 >
 >Well, the char's are all widened into the 'appropriate' int types.
 >(These are called integral promotions, or some such.)  Then the
 >appropriate comparisons of int's and/or unsigned int's are performed.
 >

  Wrong...  Not chars Dale... Pointers.

  I suspect you just misread the defines.  All three are assigning pointers
between pointer variables.  One of the cases (case 1 or 2 depending on the
implementation) is legal.  Case 3 is always illegal but will only be flagged
as a warning and an implicit cast-to-the-appropriate-pointer-type will be
done by some compilers...
  Also, there's no "comparisons" being done here at all.  The "=" operation
is an assignment.  The "==" operation is compare for equal...

---
John Stanley (john at viper.UUCP)
Software Consultant - DynaSoft Systems
UUCP: ...{amdahl,ihnp4,rutgers}!{meccts,dayton}!viper!john



More information about the Comp.lang.c mailing list