How to define function-like macro?

乃宏周 naive231 at
Mon Nov 25 21:50:53 EST 2013

I read manual already:

-D name=definition The contents of definition are tokenized and processed
as if they appeared during translation phase three in a ‘#define’
directive. In particular, the definition will be truncated by embedded
newline characters.

If you are invoking the preprocessor from a shell or shell-like program you
may need to use the shell's quoting syntax to protect characters such as
spaces that have a meaning in the shell syntax.

If you wish to define a function-like macro on the command line, write its
argument list with surrounding parentheses before the equals sign (if any).
Parentheses are meaningful to most shells, so you will need to quote the
option. With sh and csh, -D'name(args...)=definition' works.
I wrote this in my makefile:

*def_dpf = 'dpf(a...)=printk(KERN_ALERT a)'*

My code uses `dpf` macro like this:

*dpf("current value=%d\n",var);*

When I compiling my program, I got this error:

*error: ‘Da’ undeclared (first use in this function)*

Even manual says *sh* and *csh* can works with that definition,
*bash*should support that machanism, I guess. How should I do? Any
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Kernelnewbies mailing list