title: How are __FILE__ and __LINE__ expanded in kernel code?
body: <p>I'm reading Linux Device Drivers, and noticed you can print the current line and file using, for instance, printk. How is this implemented? How does Linux keep track of the line containing the printk statement? I haven't seen similar capabilities in "normal C code" written in userspace.</p>
  
  <p>Here's an example from LDD3:</p>
  
  <pre><code>printk(KERN_DEBUG "Here I am: %s:%i\n", __FILE__, __LINE__);
  </code></pre>