TIL: typedef is not recommanded with struct in C

Jan 22, 2023

Today, I learn that typedef with struct trick give you a way to use structure tag like normal type. But, it is not suggested as mentioned in Linux kernel coding style document except few scenarios.

You can read more on this from stack overflow question and some of its answers such as this or this.

In general, do NOT write this.

typedef struct point {
  int x;
  int y;
} point;

point p;

Be explicit and write this.

struct point {
  int x;
  int y;
}

struct point p;
Tags: til c