RE: MACRO - How is it working in Linux

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

 



Hi,

Pls find below the CPP processed source code. I hope you can then make out
how does it work.

main()
{
        int abc = (1 = 2);
        printf("abc = %d\n",abc);
}

~Abu.

Abu M. Muttalib
Sr. Engineer, Embedded System,
Aftek Infosys Ltd.,
Office: 91-20-25449260-65 X-256
Mobile: (0)9881322820
Email: abum@xxxxxxxxx


-----Original Message-----
From: kernelnewbies-bounce@xxxxxxxxxxxx
[mailto:kernelnewbies-bounce@xxxxxxxxxxxx]On Behalf Of Mukund JB.
Sent: Friday, February 17, 2006 7:02 PM
To: kernelnewbies
Cc: Fawad Lateef
Subject: MACRO - How is it working in Linux


Dear All,

I have seen a macro like this in the Linux kernel sources in
include/linux/usb.h line no: 1090.

#define usb_dotoggle(dev, ep, out)  ((dev)->toggle[out] ^= (1 << (ep)))

I did not understand how it works?
I have written a small usermode program to test this.

#define x 1
#define y 2
#define macro() (x = y)
main()
{
	int abc = macro();
	printf("abc = %d\n",abc);
}

This code results in a compile error.
test.c:9: error: invalid lvalue in assignment.

Why?

Regards,
Mukund Jampala


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



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