一直以为typedef必须在相应的数据类型之后才可定义,原来在前面也可以:
#include <stdio.h> #include <stdlib.h> /* the typedef is before the struct */ typedef struct pcap_if* pcap_if_p; struct pcap_if { struct pcap_if *next; int a; }; int main() { const pcap_if_p a = (pcap_if_p)malloc(sizeof(struct pcap_if)); a->a = 1; a->a = 2; printf("%d", a->a); return 0; }