September 22, 1999 Strong Typing Slide #10

Strong Typing: Hard to Get Right

C Example

        int main(void) 
        {
          unsigned char *c;
          float f = 10;
          for (c = (char *)&f; c < sizeof(float) + (char *)&f; c++) {
            printf("%u ",  *c);
          }
          putchar('\n');
          return 0;
        }
        float.c: In function `main':
        float.c:10: warning: comparison of distinct pointer types 
                    lacks a cast


Next Copyright © 1999 M-J. Dominus