一直以为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;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2023-03-29
  • 2021-08-13
  • 2021-06-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
相关资源
相似解决方案