Re: Wrong operators for the binary.

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

 



--- Jose Luis Alarcon <jlalarcon@tiggerfan.com> wrote:
>--- Tadeusz Andrzej Kadłubowski <yess@hell.org.pl> wrote:
>>On Tue, Dec 03, 2002 at 11:52:03AM -0800, Jose Luis Alarcon wrote:
>>>   Hi all.
>>> 
>>>   I am trying compile a module that contains this line:
>>> 
>>>      printk("Device: %d.%d\n", inode->i_rdev >> 8, inode->i_rdev & 0xFF);
>>> 
>>> and the result is that gcc 3.2.1 says that '>>' and '&' are wrong operators for
>>> the binary. Why?
>>
>>My guess:
>>i_rdev in inode structure is of type kdev_t, which is defined in
>>include/linux/kdev_t.h and contains one member - unsigned short value. Maybe
>>try shifting/bitwise anding not on the structure, but on that particular member
>>of the structure.
>>Then if inode is a pointer to the inode struct, then it would be something
>>like:
>>
>>printk("Device: %d.%d\n", (inode->i_rdev).value >> 8, (inode->i_rdev) & 0xff);
>>
>>This guess obviously may occur wrong. Please tell, if it worked.
>>-- 
>>tadeusz a. kadlubowski
>>
>
>  Hi Tadeusz, and thanks for your answer.
>
>  Your proposed line:
>
>   printk("Device: %d.%d\n", (inode->i_rdev).value >> 8, (inode->i_rdev) & 0xff);
>
>gets solve the problem for '>>' but not for '&'. I paste here down the output:
>
>chardev.c:91: wrong operators for the binary &
>
>  Why gcc think that & is a binary?. I suppose Ori Pomerantz use '>>' and '&' like
>bits level operators.
>
>  Thanks you, very much.
>
>  Regards.
>
>  Jose.
>

  The "solution" comes adding '.value' to the expression with '&', in this way:

printk("Device: %d.%d\n", (inode->i_rdev).value >> 8, (inode->i_rdev).value &
Oxff);

  Thanks you very much to Tadeusz Andrzej Kadubowski.

  Jose.

Debian GNU/Linux 'Sid' Kernel 2.4.19 Ext3.
ESware Linux 365 Kernel 2.5.49 ReiserFS.
Registered Linux User #213309.
Memories..... You are talking about memories.
Rick Deckard. Blade Runner.

_____________________________________________________________
Get your own free tiggerfan.com email address!!
DisneySites!! - http://www.disneysites.com/webmail/tiggerfan

_____________________________________________________________
Select your own custom email address for FREE! Get you@yourchoice.com w/No Ads, 6MB, POP & more! http://www.everyone.net/selectmail?campaign=tag
--
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