Re: Confusion with printk statements

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

 




On Wed, 13 Dec 2006, john bougs wrote:

your problems is a C syntax problem

when you use the comma it takes "<1>" as the format
string and the "[helloinit1]\n" as an argument.

In C when you have two string constants together it
concatenates them ie printk("<1>" "[helloinit1]\n");
becomes  printk("<1>[helloinit1]\n");

In other words, the lines that look like

      printk(KERN_ALERT, "[helloinit1]\n");

should be

      printk(KERN_ALERT "[helloinit1]\n");

i.e. without the comma. That is the reason for the wrong output. Might look odd at first glance but as several has pointed out this is how concatenation of string constants work in C.

/Ricard
--
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[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