I am using header file for driver so Can I define macro to call Kernel
function ?
As phrased, NO.
What are the generatl rules for defining macro.
They can be object-like (no parameters) or function-like
(with parameters.) In C89, the number of parameters for
a function-like macro must be constant; if I recall correctly, C99
has provision for variable number of arguments [I'm not sure on that.]
object-like macros are just substituted where-ever they are
found outside of quoted strings. *Whever* you have defined the
macro as will be dropped in -- it is, for example, perfectly
legal to
#define BEGIN {
#define END }
and then code
if (foo) BEGIN i++; END
function-like macros are substituted when they are found outside of
quoted strings in a function-like context. The actual parameters you
supplied are textually dropped in in place of the placeholders of the
macro definition. Again, it is not necessary that the definition expand
to a complete statement or complete syntactical grouping: like
object-like macros, function-like macros can be used to introduce new
syntactic sugar.
There are rules about re-scanning the text and re-subtituting, and
there are rules that prevent recursive macro expansion.
So... macros can be used to substitute in text, and the result will
have the same effect as if you had originally written the text at that
point (except as modified by the non-recursion rule.)
You thus cannot do anything with macros that you couldn't just write
yourself by hand.
Now, the reason that I said above that NO, you cannot define macros to
call kernel functions, is that macros cannot "call" -anything-:
they can just do textual substitutions. The substituted text
might happen to be such that after compilation and linking a
kernel function would be called at that point -- but only to
exactly the same extent that the context would have permitted
you to put in the C code for the kernel call manually. Macros
do not add any additional power to call kernel functions;
nor do they reduce that power: they merely provide alternative
ways of writing text that will expand to the same code.