help with preprocessor tricks

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

 



Hi,

I have the following code:
--------------------------------
#define NEWLN "\n"

#define MYDBG1 1
#define MYDEBUG1(fmt, args...) \
  if (MYDBG1) printk(KERN_DEBUG fmt NEWLN, ## args )
--------------------------------

What is intended is that, using MYDEBUG1 as:
 MYDEBUG1("some debugging info %d %x", var1, var2);

should produce:
 printk(KERN_DEBUG "some debugging info %d %x" "\n", var1, var2);

which will become:
 printk(KERN_DEBUG "some debugging info %d %x\n", var1, var2);

thus saving a valuable "\n" and sparing me from RSI !!!!! ;)

But the above macro doesn't do the job. It produces the following:
 if (1 ) printk("<7>"   "some debugging info %d %x"  , var1, var2);

Any pointers to bugs?
BTW, this works in userspace but not in kernelspace.

ciao,
Amit

-- 
The statement below is true.
The statement above is false.
^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^-^
                  Amit Kucheria
          EECS Grad. Research Assistant
         University of Kansas @ Lawrence
   (R)+1-(785)-830 8521 ||| (O)+1-(785)-864 7774
____________________________________________________


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[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