Understanding Forward Declarations in C
One of the best ways to learn systems programming is by reading real-world code. Recently, while reading the Linux kernel source, I noticed something interesting inside drivers/pinctrl/core.h: #include <linux/kref.h> #include <linux/list.h> #include <linux/mutex.h> #include <linux/radix-tree.h> #include <linux/types.h> #include <linux/pinctrl/machine.h> struct dentry; struct device; struct device_node; struct module; At first glance, these lines seem incomplete. We see declarations like struct device; but no actual definition. Where is the complete structure with all its members? Why didn’t file defining this structure isn’t included? ...