<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 20, 2015 at 3:03 AM, Ahmed Soliman <span dir="ltr"><<a href="mailto:ahmedsoliman0x666@gmail.com" target="_blank">ahmedsoliman0x666@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">currently I started reading through the linux kernel and I started<br>
reading liunx/include/linux/list.h> I understood some of the functions<br>
but still I dont know what does these lines of code do<br>
#ifndef _LINUX_LIST_H<br>
#define _LINUX_LIST_H<br>
which exist at the very beginning of the file<br>
I also noticed that there is many similar ifndefs in almost any .h<br>
file in the kernel<br>
note that I understand wnat does ifndef do bu I dont understand what<br>
goal is it supposed to achieve at the beginning of the headerfile<br></blockquote><div><br></div><div>It makes sure that the file doesn't get included twice.Suppose</div><div>you have a.c and a.h file and you have #include "thisfile"(where</div><div>you have that #ifndef thing) in both a.c and a.h file then it will</div><div>be included only once. Because once .c or .h includes it then</div><div>that particular #define is already defined so next time it will</div><div>not execute when someone tries to include it again.</div><div><br></div><div>Hope that helps.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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></div>