what is the use of #ifndefs
aruna.hewapathirane at gmail.com
Tue Jul 21 15:44:58 EDT 2015
>> I dont understand what goal is it supposed to achieve
>> at the beginning of the headerfile
The 'goal' is to prevent 'redefinition' errors, like Stephan Müller said it
is a 'include guard'.
A explanation of why and how to use include guards can be found here:
When I try : find . -name "*.c" -o -name "*.h" | xargs grep -i "include
<linux/list.h>" | wc -l
It gives me 1319 instances where list.h is being included, imagine your
function being redefined that many times. Not only will gcc bitch and
complain about redefinition errors but go screaming into the night like
Valdis says.. [grin]
If you still have difficulty understanding why, the best way would be to
write some simple code yourself then compile, you will start to see why we
require the #ifndef.
Thanks - Aruna
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Kernelnewbies