[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using #define preprocessor



Also sprach TongEng Chiah:
} i read through some kernel codes and notice the use of
} #define
} 
} i was wondering whether i can made use of it in the
} way described below
} 
} i want to write a module called MYMODULE
} in this module i define: #define mymodule
} 
} so in the kernel codes, i want to add in some
} conditions
} 
} #ifdef mymodule
}    blah
}    blah
} #endif
} 
} the codes will only be run if MYMODULE has been loaded
} else, the codes won't run.
} 
} is what i described above possible?
} how can it be done?
} 
Sure it's possible. You'd just have to muck with the Makefiles and the
script which generates those. However, you should ask whether you should
do this or not. The idea of a driver/module is that it's a separate piece
of code which the kernel supports. The kernel does very well at
supporting them, so there shouldn't be a need for you to muck with the
kernel code proper in order to make your module run. Also, remember that,
if you compile it into the kernel, it'll run even if your module hasn't
been loaded yet. This could cause bad things to happen...

-- 
|| Bill Wendling			wendling@ganymede.isdn.uiuc.edu
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.surriel.com/kernelnewbies.shtml