Re: help with preprocessor tricks

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

 




I could not understand what you were doing with that if-statement. The
following works for me:

#define k_message(msg...) printk(KERN_INFO msg)

if you want to make it conditional w.r.t. MYDEBUG it would look like

#ifdef MYDEBUG
  #define ...
#else
  #define ...
#endif


On Mon, 25 Feb 2002, Amit Kucheria wrote:

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

-- 
-Pradeep
-----------------------------------
Let us be the change, we wish to see in this world.
                        --- Mahatma Gandhi
-----------------------------------
Pradeep Jagannath
pradeep@it.iitb.ernet.in
http://www.it.iitb.ernet.in/~pradeep

-----------------------------------


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