<div dir="ltr">This is to avoid multiple declarations.In header file you declare the variables and function names and these have to be declared just once otherwise you will get multiple declaration error.<div>#ifndef avoids this error .By placing it at the top all the declaration is visited just once =&gt;How?Since suppose  <span style="font-size:12.7272720336914px">_LINUX_LIST_H is not defined and when you enter the file #ifndef (if not defined) will be true , hence it will go to next line and define it using </span><span style="font-size:12.7272720336914px"> </span><span style="font-size:12.7272720336914px">#define _LINUX_LIST_H .Now Since #defines(Macros) have global scopes across all the files, if suppose in some other files you have included this file (which defines above macros) , it will check first #ifndef _LINUX_LIST_H , but since it has already been defiend it will not enter the next line and you will be saved from multiple </span>declaration<span style="font-size:12.7272720336914px"> error.</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 21, 2015 at 7:54 AM, Navy <span dir="ltr">&lt;<a href="mailto:navych@126.com" target="_blank">navych@126.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, Jul 20, 2015 at 12:03:07PM +0200, Ahmed Soliman wrote:<br>
&gt; currently I started reading through the linux kernel and I started<br>
&gt; reading liunx/include/linux/list.h&gt; I understood some of the functions<br>
&gt; but still I dont know what does these lines of code do<br>
&gt; #ifndef _LINUX_LIST_H<br>
&gt; #define _LINUX_LIST_H<br>
&gt; which exist at the very beginning of the file<br>
&gt; I also noticed that there is many similar ifndefs in almost any .h<br>
&gt; file in the kernel<br>
&gt; note that I understand wnat does ifndef do bu I dont understand what<br>
&gt; goal is it supposed to achieve at the beginning of the headerfile<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Kernelnewbies mailing list<br>
&gt; <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
&gt; <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noreferrer" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br>
The whole structure seems to<br>
#ifndef ...<br>
#define ...<br>
.<br>
.<br>
.<br>
#endif<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noreferrer" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</blockquote></div><br></div>