how does current->pid work for linux?

c, linux, process

Solution

You're looking for `#include <linux/sched.h>`. That's where `task_struct` is declared.

Problem

Do I need to include a library? Can anyone please elaborate in it? I know is used to get the process id of the current task where is being called from But I want to printk something with current->pid `printk("My current process id/pid is %d\n", current->pid);` ...and is giving me an error `error: dereferencing pointer to incomplete type`

Original source