`
yaojingguo
  • 浏览: 202422 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Code demostrating "Distinguishing C++ Declarations from Expressions"

阅读更多

Code demostrating "Distinguishing C++ Declarations from Expressions" in The Definitive ANTLR Reference.

 

#include <stdio.h>

typedef int I;
char x = 'a';
void foo() {
  I(x);
  x = 10;
  printf("x = %d in foo\n", x);
}

struct _node {
  int m;
};

typedef struct _node * T;

T(*a)(int);
int main(int argc, const char *argv[]) 
{
  printf("cast %d, %d\n", I(x), (I)x);
  foo();
  printf("x = %d in main\n", x); 

  struct _node n;
  T one = &n;
  T *a = &one;

  T(*a)->m = 8;
  printf("m: %d\n", (*a)->m);
  return 0;
}
 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics