How to define function-like macro?

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

 



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 suggestion?
 


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux