Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Either -> is a binary operator or is is not an operator in the expression at all, and the unary postfix operators are ->b, ->c, and ->d. In the latter case, that gives us (->d (->c (->b a))) in Lisp, which I can see how ypu could get, but I don't agree.

    #include <stdio.h>
    #include <stdlib.h>

    struct foo {
      int a;
    };

    int main() {
      struct foo *f = malloc(sizeof(struct foo));
      f->a = 5;
      printf("%d\n", f->b);
      free(f);
      return 0;
    }


    test.c:11:21: error: no member named 'b' in 'struct foo'
       11 |   printf("%d\n", f->b);
          |                  ~  ^
    1 error generated.
What do you mean when you say fields are not first class in C?


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: